Jump to content

Recommended Posts

so i've been developing in the CodeIgniter framework and i have yet to code an object. My app deals with bookings. So in the database i have columns like: start, end, created, created_by, title, description, etc. I pull the data out and put it into an array. I use my controller functions to validate data and model functions to delete/edit/create the bookings. Should i write a class that creates a Booking object? i don't see how that would benefit me though.

 

How do you guys determine what needs to be an object?

From what I understand, the differences aren't vast.  There are some links I've clicked through while researching this myself and found some results that show associated arrays are a bit faster ( http://stackoverflow.com/questions/8498114/should-i-use-an-associative-array-or-an-object ). 

 

The difference in building them is miniscule anyway.  In CI your models are class extensions, so they are inherently prepared for object building and the active record is set up for object construction unless you request it in array format.

 

$this->result() versus $this->result_array()

 

The way I go about it is to create everything as an object and reference it to $this->data to pass to the view.

I always use arrays when using data from a database. A lot of the array functions don't work on objects, so if you want to use them you'll have to at some point convert the object to an array - which is just a waste of time when you could have used arrays to start with.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.