Welcome Guest, Not a member yet? Register   Sign In
Manipulating data returned by Model
#1

[eluser]Unknown[/eluser]
Hi guys,

This is a newbie question... I got the following model function returning all the blog posts in the database matching the criterias :

Code:
function get_posts($id_website,$limit){
        $this->db->select('*');
        $this->db->from('blog_post');
        $this->db->where('id_website',$id_website);
        $this->db->orderby('post_date','desc');
        $this->db->limit($limit);
        $query = $this->db->get();
        return $query;
    }

Since I'm going to use that function over many controllers, I'd like to do some data manipulation and cleansing before returning the data to the controller. For example, i'd like to tranform fields that returns 0 or 1 to yes or no, do calculation on implied values, or be able to create a new property to the returned object... What would be the best practice in order to achieve this ?


Messages In This Thread
Manipulating data returned by Model - by El Forum - 08-04-2010, 10:26 AM
Manipulating data returned by Model - by El Forum - 08-04-2010, 10:35 AM



Theme © iAndrew 2016 - Forum software by © MyBB