Codeigniter活动记录在/ db.field = db.field [英] Codeigniter Active Record HAVING / WHERE db.field = db.field
本文介绍了Codeigniter活动记录在/ db.field = db.field的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人可以告诉我,如果有活动记录,这是否可行-以及如何?
Can someone tell me, if this is possible with active record - and how??
$this->db->select('*');
$this->db->from('table1');
$this->db->join('table2', 'table1.id = table2.fi_id', 'left');
$this->db->having('table1.second_id','table2.fi_second_id', false);
$query = $this->db->get();
问题在于, table2.fi_second_id始终被视为字符串-不作为数据库字段。在哪里也尝试过-同样的问题。
The problem ist, that 'table2.fi_second_id' is always treated as a string - not as a database field. Tried this with 'where' also - it's the same problem.
Thx
推荐答案
我认为您需要以下内容:
I think that you want the following:
$this->db->having('table1.second_id = table2.fi_second_id',false);
您可以或可以不使用 false
参数,如果您不需要转义的SQL查询。
You may or may not apply the false
parameter if you don't need escaped SQL queries.
这篇关于Codeigniter活动记录在/ db.field = db.field的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文