[eluser]mhiggins[/eluser]
I am tidying up an application (trying to avoid rewriting) that has a few different methods/formats for passing data from the Model back to the Controller. I want to update the method I use to be uniform across the Application and also make it easier for the following requirements:
- Potential to AJAX-ify some of the interface so I may need a Controller to return JSON data, and perhaps even XML for a public API (in the future).
- The data is structured and may range from a single value right up to a multi-D array.
- Potential to serialize a data object and save it to the DB so I can 'snapshot' the object at a point in time before making any changes to it.
- Potential to Cache data objects at the model-level rather than caching the HTML view. So, if users request the HTML page, JSON via AJAX or XML via API then I can cache a single data object and return it to all three requests as its the same underlying data object.
- In Views it would be great if I can use a simple, straight forward naming convention for variables so designers can work with them rather than $tmp_array[3][3][id] or such.
At the moment I am using a combination of
and
Code:
query->result_array()
and looping through in the view when needed.
I would really like to get input from others out there who have thought about this and solved some of these problems.
Thanks in advance.