|
Posted by Chung Leong on 09/27/62 11:37
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.
Navigation:
[Reply to this message]
|