Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
October 5, 2005, 3:33 pm
rate this thread
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
Thanks in advance for advises.
Re: Different between mysql_fetch_object and mysql_fetch_assoc/array?
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
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
respectively. I like using mysql_fetch_object because it seems natural
to me to reference with ->field, but it's up to you.