Jump to content

mysql_fetch_object


allex01

Recommended Posts

I did read the links you provided but still not sure of the difference. Here's what they say

 

mysql_fetch_object() is similar to mysql_fetch_array(), with one difference - an object is returned, instead of an array. Indirectly, that means that you can only access the data by the field names, and not by their offsets (numbers are illegal property names).

 

Well What is the difference between object and array. They mention is mysql_fetch_object() can only access data by field name. Isn't that the same for mysql_fetch_assoc(). How do they differ.

Link to comment
https://forums.phpfreaks.com/topic/93781-mysql_fetch_object/#findComment-480542
Share on other sites

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]

 

I prefer using an Array. But that is Just me :)

Link to comment
https://forums.phpfreaks.com/topic/93781-mysql_fetch_object/#findComment-480547
Share on other sites

Can you briefly explain what is the purpose or advantages of using classes and objects in php compared to just using stand alone functions.

 

No, sorry, but a brief explination would be near on impossible. Once you start using classes/objects and then get further into design patterns things will start to click, but without that experience the question 'what is the purpose or advantages of using classes and objects in php compared to just using stand alone functions' will still make sense.

Link to comment
https://forums.phpfreaks.com/topic/93781-mysql_fetch_object/#findComment-480616
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.