Welcome Guest, Not a member yet? Register   Sign In
Object results vs Array results
#1

[eluser]Buso[/eluser]
What would be the pros/cons of each? Or is it just a matter of taste?

I have been using array results from the beginning, and I find them very useful when I want the parser to recognize them, or process them with different array functions like array_merge, array_unique, etc.

But I noticed that most ppl use object results.. Is there a reason for that?
#2

[eluser]WanWizard[/eluser]
I use array's as well, mainly for the same reason as you. And using array's is slightly more economical (in terms of memory usage and performance).
#3

[eluser]Buso[/eluser]
Oh great. I'm glad to hear that from an expert Smile
#4

[eluser]donald.tbd[/eluser]
Sorry for bringing up an old thread but i have the same question. So far i have only seen more pros to arrays. But what are the pros of an object?
#5

[eluser]WanWizard[/eluser]
It all depends on the what the object contains, and what you intend to do with it.

In terms of data manipulation and cost (processing, memory), array's are a better choice. Also arrays are simpler to serialize (for example if you store them in a session).

Objects however allow you to embed code as well, protect data structures inside the object, etc. They also allow you to make relations ( $this->that ) which are heavily used by for example ORM implementations.




Theme © iAndrew 2016 - Forum software by © MyBB