Welcome Guest, Not a member yet? Register   Sign In
Acrive Record: Getting the row total then setting limit clause
#4

[eluser]Armchair Samurai[/eluser]
I'd do it this way.

Code:
function get($limit, $offset)
{
    $data = new stdClass;

    $this->db->start_cache();
        $this->db->from('product');

        if ($this->brandid)
            $this->db->where('brandid', $this->brandid);
    $this->db->stop_cache();

    $data->count = $this->db->count_all_results();

    if ($data->count == 0)
    {
        $data->product = array();
    }
    else
    {
        $this->db->limit($limit, $offset);

        $query = $this->db->get();
        $data->product = $query->result();
    }

    $this->db->flush_cache();
    return $data;
}


Messages In This Thread
Acrive Record: Getting the row total then setting limit clause - by El Forum - 11-07-2008, 03:58 PM



Theme © iAndrew 2016 - Forum software by © MyBB