【问题标题】:Codeigniter Active Record HAVING / WHERE db.field = db.fieldCodeigniter Active Record HAVING / WHERE db.field = db.field
【发布时间】:2013-02-27 21:29:51
【问题描述】:

有人可以告诉我,如果这可以通过活动记录实现 - 以及如何实现?

$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' 始终被视为 字符串 - 而不是 数据库字段。也用'where'试过这个 - 这是同样的问题。

谢谢

【问题讨论】:

  • 为什么不使用$this->db->query()的简单查询,它更灵活。

标签: php mysql codeigniter activerecord


【解决方案1】:

我认为您需要以下内容:

$this->db->having('table1.second_id = table2.fi_second_id',false);

如果您不需要转义 SQL 查询,您可以应用也可以不应用 false 参数。

【讨论】:

  • 别忘了接受答案或投票!欢迎使用 Stack Overflow!
猜你喜欢
  • 1970-01-01
  • 2015-09-17
  • 1970-01-01
  • 2013-05-04
  • 1970-01-01
  • 2017-11-30
  • 2011-11-25
  • 2016-02-25
  • 2013-01-24
相关资源
最近更新 更多