Re: Different between mysql_fetch_object and mysql_fetch_assoc/array?
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.php archive

Re: Different between mysql_fetch_object and mysql_fetch_assoc/array?

From: Marcus <JumpMan222@aol.com>
Date: Wed Oct 05 2005 - 21:21:59 CEST

Alucard wrote:
> Hi all.
>
> I am a newbie in PHP. Recently I found that there are mainly two ways
> to fetch mysql(or other DB) data: by object or by array.
>
> What is the main differences between them? Will the server use more
> resources (just my thought) when fetching by object? Or any other
> reasons?
>
> Thanks in advance for advises.
>

In my experience there is no difference between the two. I would guess
that if you got down to specifics fetching by array *might* be a bit
faster, but I think it would be so small it wouldn't affect your script
at all.

The difference is after you run your query with either:

$row = mysql_fetch_object($result) or
$row = mysql_fetch_array($result)

you would reference your fields by

$row->field or
$row[index]

respectively. I like using mysql_fetch_object because it seems natural
to me to reference with ->field, but it's up to you.
Received on Tue Oct 18 02:32:23 2005