Jump to content

Which of these functions is better to use?


aeroswat

Recommended Posts

If you want to reference by field name use mysql_fetch_object, if you dont care about field names and just want indexes use mysql_fetch_array (you can get field names with this aswell)..

 

Or alternatively you could use mysql_fetch_assoc with a flag... it really depends on you..

 

There are other reasons for using specific ones but again it depends on what you want to do with the result

If you want to reference by field name use mysql_fetch_object, if you dont care about field names and just want indexes use mysql_fetch_array (you can get field names with this aswell)..

 

Or alternatively you could use mysql_fetch_assoc with a flag... it really depends on you..

 

I thought that one was better to use than the other though? Like more resource efficient.

The best way to find out which one to use is to look it up :)

http://www.php.net/manual/en/function.mysql-fetch-array.php

http://www.php.net/manual/en/function.mysql-fetch-object.php

http://www.php.net/manual/en/function.mysql-fetch-assoc.php

 

Edit: My above post was wrong.. mysql_fetch_array uses flags NOT mysql_fetch_assoc.. My Bad..

I thought that one was better to use than the other though? Like more resource efficient.

 

Don't you have any other things to optimise?

 

I would guess array will take a bit less memory than object, but seriously, you should use whichever better suits your application design.

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.