Re: MySQL Fetch_Array VS. Fetch_Object
| From: | Philip Olson | Date: | Wed, 30 Jan 2002 20:25:23 +0000 |
| Subject: | Re: MySQL Fetch_Array VS. Fetch_Object | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-82812@lists.php.net to get a copy of this message | ||
There is no performance/speed issue, the two are identical in speed.
This is a personal preference issue. Although, extract() does not
work on objects, only arrays.
Also, when using _fetch_array, use the second optional parameter,
for example:
$row = mysql_fetch_array($result, MYSQL_ASSOC);
Or just use mysql_fetch_assoc(). Regarding extract(), if this is the
desired affect (as proposed in the original question), then:
SELECT foo FROM bar
extract($row);
print $foo;
Now, mysql_fetch_row is _slightly_ faster then both of these but
who's counting.
Regards,
Philip Olson
On Wed, 30 Jan 2002, Bryan Gintz wrote:
> Personal preference, and all my code is written with that so far, but
> seeing about the speed issue, that might change.
>
> Thanks.
>
> Jim Lucas [php] wrote:
>
> >oh and mysql_fetch_object is a little slower then mysql_fetch_array()
> >
> >Jim Lucas
> >----- Original Message -----
> >From: "Bryan Gintz" <bgintz@jtlnet.com>
> >To: "PHP List" <php-general@lists.php.net>
> >Sent: Wednesday, January 30, 2002 10:48 AM
> >Subject: [PHP] MySQL Fetch_Array VS. Fetch_Object
> >
> >
> >>Does anyone know what the pros and cons of using mysql_fetch_object vs.
> >>mysql_fetch_array.
> >>
> >>I find it easier to use the object version because you dont have to code
> >>any extra statements to put them into regular variables.
> >>
> >>print "$obj->field_name";
> >>as opposed to
> >>$field_name = $row["field_name"];
> >>print "$field_name";
> >>
> >>Im just curious to see if there are any problems (resources, etc) that
> >>come with using the object method???
> >>
> >>
> >>
> >>--
> >>PHP General Mailing List (http://www.php.net/)
> >>To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> >>For additional commands, e-mail: php-general-help@lists.php.net
> >>To contact the list administrators, e-mail: php-list-admin@lists.php.net
> >>
> >>
> >
> >
>
>