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
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
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
Share on other sites

The famous analogy is an Object is like a cat. it can do things like meow and sleep and also it can have properties like color and weight at the same time. OOP is more 'black box' like. you really don't _need_ to know it.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.