如何在Codeigniter中使用多个where子句?

罗伊

对于我的数据库查询,我必须在Codeigniter PHP中使用多个where子句查询。我写了这样的代码:

 $this->db->and_where_in('category_name,publication_status','home_headline_sub',1);

但是此查询显示浏览器中的数据库查询错误。然后我写了这个查询:

$this->db->where('category_name,publication_status','home_headline_sub',1);

但是它仍然会给出错误。谁能帮我解决这个问题?提前致谢。

克雷因

您可以链接数据库子句,因此您可以将其写为

$this->db->where('category_name','case')->where('publication_status','case')->where('home_headline_sub','case');

这将生成查询的WHERE子句,如下所示:

// WHERE category_name = 'case' AND publication_status = 'case' AND home_headline_sub = 'case'

此处的文档:http : //ellislab.com/codeigniter/user-guide/database/active_record.html#chaining

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章