开发者

codeigniter - subquery limit not showing

开发者 https://www.devze.com 2023-03-11 19:36 出处:网络
I have this: $this->db->select(\'(select var_value from contents where table = \"products\" and table_id = products.id and var_name = \"image\" and n开发者_JAVA技巧ame = \"images\" order by id

I have this:

$this->db->select('(select var_value from contents where table = "products" and table_id = products.id and var_name = "image" and n开发者_JAVA技巧ame = "images" order by id asc limit 1) as main_picture');

$this->db->where('category_id', $cat)->from('products')->limit($limit, $start)->get();

The problem is that codeigniter is removing the "limit 1" inside the subquery...

Any advice?

Thx!


You can not use LIMIT inside $this->db->select(); method
Please refer to Active Record documentation

  • $this->db->get();

  • $this->db->get_where();

Are the only methods that allow the use of LIMIT

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号