in reply to Re: Re: DBI returning mysql columns in strange order.
in thread DBI returning mysql columns in strange order.

There is a method to my madness. I choose select * from ... because the code is meant to work on a collection of tables whose columns are all different.

My application involved having a group of small tables. Then I would have this code query and display any table that was selected. I'm trying to be lazyTM

Neil Watson
watson-wilson.ca

Replies are listed 'Best First'.
Re: Re: Re: Re: DBI returning mysql columns in strange order.
by mpeppler (Vicar) on Oct 10, 2003 at 00:01 UTC
    Well - as long as you are aware of the pitfalls of that technique...

    Michael

Re: Re: Re: Re: DBI returning mysql columns in strange order.
by EdwardG (Vicar) on Oct 10, 2003 at 11:29 UTC

    With respect, this is not a good enough reason to use SELECT * - I'll try to explain why.

    The main danger is that at some future time, someone (perhaps not you) will add a BLOB column to one of your tables. If this happens, your code as is could blithely start dragging this data across a network. I don't know MySQL so well, but in SQL Server this could be anything up to about 2GB, perhaps more. Plenty enough to provoke the wrath of most Network Administrators.

    You might be lucky - your code could fail due to some exceeded limit, or you might be unlucky - your code could work, and quietly start a mammoth data transfer.

    If you really have your heart set on your current approach, you might want to consider thinking about a maximum limit to the amount of data returned in a column, and then explicitly set this limit with code similar to this:

    $dbh->{LongReadLen}=1024*200; # Max size of column data $dbh->{LongTruncOk}=0; # Not OK to truncate data
      Which is why DBI drivers should default the LongReadLen value to some reasonable amount (DBD::Sybase defaults it to 32K as that is the normal default for Sybase connections), and I see that the DBI manual actually states that the default should be 0, meaning "do not fetch BLOB columns" (and made me realize that DBD::Sybase does not behave correctly when LongReadLen is set to 0...)

      Michael