activerecord - codeigniter,使用事件记录自定义选择数据

标签 activerecord codeigniter

我想询问是否需要在我的应用程序中执行此查询

select qty, type from tItem where qty=0 and (type=1 or price=100)

如何使用代码点火器中的事件记录来做到这一点?

因为如果我这样做

$this->db->where('qty','0');
$this->db->where('type','1');
$this->db->or_where('price','100');

查询就像

select qty, type from tItem where qty=0 and type=1 or price=100

这不是我的本意

最佳答案

您可以传递自定义子句,如下所示:

$this->db->where('(type = 1 OR price = 100)');

关于activerecord - codeigniter,使用事件记录自定义选择数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1999305/

相关文章:

ruby-on-rails - 需要帮助理解 Rails 事件记录查询

php - Codeigniter 发送电子邮件 OpenSSL 错误

php - 使用 CodeIgniter 上传多个图像

php - codeigniter Zip编码类添加多个文件

php - 如何使用当前列值加上 codeigniter 的增量来更新列值?

php - CodeIgniter 路由将所有 URI 段映射到一个 Controller /方法

ruby-on-rails - ActiveRecord destroy_all

javascript - Rails 5 AJAX 拒绝渲染部分内容

ruby-on-rails - Rails连接表问题

ruby-on-rails - 在 `find_or_create_by` `has_many` 关联上使用 `through` 时出错