Welcome Guest, Not a member yet? Register   Sign In
Active Record Error
#1

[eluser]satanrulehis[/eluser]
Hi all!

I want to pagination,I have a problem with my sql like this:
Code:
$this->db->where('product_catalog.id', $catalogid);
$this->db->where('product.active', 1);
$this->db->from('product_catalog');
$this->db->join('product', 'product_catalog.id = product.catalog_id');
$this->db->select('product_catalog.name as catalogname, product.id, product.name, product.product_code, product.small_pic, product.price');

It work:
Code:
$query = $this->db->get();

It doesn't work:
Code:
$query = $this->db->get($num, $offset);

Another question is: if I change this active record to normal sql, it doesn't work when I add $num, $offset into it

Code:
$sql = "SELECT c.name as catalogname,p.id,p.name,p.product_code,p.small_pic,p.price FROM  product p, product_catalog c where c.id=".$catalogid." and c.id=p.catalog_id and p.active=1 limit ".$offset.",".$num;

Thanks all for reading
#2

[eluser]satanrulehis[/eluser]
sorry about my wrong statement in active record in last post. I read again documentation and try but the order is correct?

Code:
$this->db->limit($num, $offset);
        $this->db->where('product_catalog.id', $catalogid);
        $this->db->where('product.active', 1);
        $this->db->from('product_catalog');
        $this->db->join('product', 'product_catalog.id = product.catalog_id');
        $this->db->select('product_catalog.name as catalogname, product.id, product.name, product.product_code, product.small_pic, product.price');
        $query = $this->db->get();

please answer my 2nd question in last post

Thanks all
#3

[eluser]Thorpe Obazee[/eluser]
What's the query being produced? and what do you want to produce?

By the way, this isn't a topic for the 'Bug Reports' forum.




Theme © iAndrew 2016 - Forum software by © MyBB