Welcome Guest, Not a member yet? Register   Sign In
Set Posts activ/inactiv
#4

[eluser]TWP Marketing[/eluser]
Zimooon, pass the active var to your function, which defaults to FALSE (0),
If you pass TRUE (1) the function should set the query where clause:

Code:
function getPosts($active = FALSE) {
    if($active == TRUE)
    {
     $this->db->where('active',1);
    }
    $query = $this->db->get('posts');
    $posts = array();

    foreach ($query->result() as $row) {
        $posts[] = array(
            'id' => $row->id,
            'title' => $row->title,
            'content' => $row->content,
            'date' => $row->date,
            'active' => $row->active
            
            
        );
    }

    return $posts;
}


Messages In This Thread
Set Posts activ/inactiv - by El Forum - 04-15-2011, 01:52 AM
Set Posts activ/inactiv - by El Forum - 04-15-2011, 04:31 AM
Set Posts activ/inactiv - by El Forum - 04-15-2011, 08:34 AM
Set Posts activ/inactiv - by El Forum - 04-15-2011, 12:06 PM
Set Posts activ/inactiv - by El Forum - 04-18-2011, 09:43 AM
Set Posts activ/inactiv - by El Forum - 04-18-2011, 10:48 AM
Set Posts activ/inactiv - by El Forum - 04-19-2011, 01:11 AM
Set Posts activ/inactiv - by El Forum - 04-19-2011, 03:55 AM
Set Posts activ/inactiv - by El Forum - 04-19-2011, 01:18 PM



Theme © iAndrew 2016 - Forum software by © MyBB