I’m not referring to a particular database driver or so but we, as PHP developer, have always had the choice to use either arrays or object as return type of a database query.
So for example we could access the column “title” with either $array['title'] or $object->title.
For example mysql PHP built-in functions mysql_fetch_assoc() and mysql_fetch_object() give this choice.
I noticed that the object-way (as I’m gonna call it) is much worse:
- You cannot specify table names that contains special chars such as
.or-and use them with objects. - Object are usually heavier than arrays
- Object doesn’t have all the cool functions to manage them as arrays do
- Arrays better explain the table structure rather then property chaining.
There are few other little things about object vs array war regarding database results but these are the main ones.
Why do people even take the object-way as choice?
1 Answer