|
Posted by Andy Hassall on 09/26/02 11:37
On 17 Jan 2006 13:56:02 -0800, "Chung Leong" <chernyshevsky@hotmail.com> wrote:
>sam.s.kong@gmail.com wrote:
>> As far as I know, there's no such function in PHP and I can make one.
>> My question is whether it's good in PHP.
>>
>> pseudo-code:
>>
>> $data = get_data("select * from table1");
>> $var = $data[3][2]; //value at 4th row, 3rd column
>>
>> This way, I can wrap db connection, data retrieval, and error handling
>> with one function (or maybe a class).
>> Is the idea workable?
>
>It's a pretty normal practice. I do it all the time. I typically have a
>number of functions, for retrieving a single row, multiple rows, a
>single column, and a single value.
>
>I believe that's also something that the MySQL manual recommends, to
>alleviate lock issues.
Isn't the default mode of operation for MySQL to send the entire result set
over to the client, then release locks, and only then actually make the results
available to the client application - so you can be as slow as you like reading
them from the client buffer, it doesn't matter?
If you're using unbuffered queries, _then_ it would matter how quickly you
consume the data, but you don't tend to see as many examples of that.
--
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
Navigation:
[Reply to this message]
|