I have always fetched database results as Arrays and NOT Objects and the reason being PHP provides so many functions to manipulate arrays that it makes my life easy.
I went over this SO Question Objects or Arrays?
But it does not answer my question. Guy who worked before in my project always fetched results as Objects and it gave me a real hard time converting it to arrays and then manipulate them since I was generating leads statistics. Array Functions made it easy.
Is there an easy way to do so? or Any other Alternative? Why go for Objects and not Arrays?
NOTE: I am not considering performance but my ease of manipulation.
ArrayObjectsand then to use:getArrayCopy()to convert it into an array (Maybe you don't even have to convert it to an array, if the arrayObject has the functionality which you want: php.net/manual/en/class.arrayobject.php). Or you can also try to simply cast them, e.g.$array = (array) $myObject;ArrayObjectclass is very useful as it allows 'property access' as well as 'index access'.Visitobject, which has fields$id,$ip_address,$visit_time, etc. ... ", and then you don't have to read the query (which might be ten files away, dynamically generated, or a hundred lines long) to know what fields you should be using. And you can use static analysis tools to validate your code while you write it.