aeroswat Posted December 22, 2009 Share Posted December 22, 2009 mysql_fetch_object or mysql_fetch_array Link to comment https://forums.phpfreaks.com/topic/186024-which-of-these-functions-is-better-to-use/ Share on other sites More sharing options...
Buddski Posted December 22, 2009 Share Posted December 22, 2009 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 Link to comment https://forums.phpfreaks.com/topic/186024-which-of-these-functions-is-better-to-use/#findComment-982341 Share on other sites More sharing options...
aeroswat Posted December 22, 2009 Author Share Posted December 22, 2009 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. Link to comment https://forums.phpfreaks.com/topic/186024-which-of-these-functions-is-better-to-use/#findComment-982342 Share on other sites More sharing options...
Buddski Posted December 22, 2009 Share Posted December 22, 2009 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.. Link to comment https://forums.phpfreaks.com/topic/186024-which-of-these-functions-is-better-to-use/#findComment-982345 Share on other sites More sharing options...
Mchl Posted December 22, 2009 Share Posted December 22, 2009 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. Link to comment https://forums.phpfreaks.com/topic/186024-which-of-these-functions-is-better-to-use/#findComment-982351 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.