Is this a good idea?



Hi!

I've been programming ASP for 5 years and am now learning PHP.
In ASP, you can use GetRows function which returns 2 by 2 array of
Recordset.
Actually, it's a recommended way in ASP when you access DB as it
disconnects the DB earlier.
Also, it's handy as you can directly access any data in the array
without looping.

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?

TIA.
Sam

.



Relevant Pages

  • Re: Is this a good idea?
    ... I've been programming ASP for 5 years and am now learning PHP. ... it's handy as you can directly access any data in the array ... There are times when it's better to dump a table into an array - like when you have a lot of processing to do on multiple items and want to release mysql resources. ...
    (comp.lang.php)
  • Re: mit asp möglich ? -php array
    ... PHP (besonders die Array Funktionen) in ASP umsetzen ... >überhaupt nicht verstehst in ASP nachbilden zu wollen. ... >nebensächlich, denn die meisten Grundlagen sind gleich, ...
    (microsoft.public.de.inetserver.iis.asp)
  • Re: Is this a good idea?
    ... > I've been programming ASP for 5 years and am now learning PHP. ... it's handy as you can directly access any data in the array ... > As far as I know, there's no such function in PHP and I can make one. ... that includes it doesn't have to worry about resources. ...
    (comp.lang.php)
  • Re: NEWBIE
    ... > I want to directly access the the individual values in an array by using ... > their keys. ... Can this be done in PHP? ...
    (comp.lang.php)
  • Re: Is this a good idea?
    ... > I've been programming ASP for 5 years and am now learning PHP. ... you can use GetRows function which returns 2 by 2 array of ... it's handy as you can directly access any data in the array ... > As far as I know, there's no such function in PHP and I can make one. ...
    (comp.lang.php)