Kohana 查询生成器 : and or where clause

标签 kohana builder

            ->where('orders.date_paid', 'BETWEEN', array($from, $to))
            ->and_where('orders.status', '=', 'new')
            ->or_where('orders.status', '=', 'delivered')

我想显示 date_paid 在 $from 和 $to 之间的所有行,其中状态为新的或已交付。

当我添加这个 or_where() 时,它会忽略 BETWEEN $from 和 $to date_paid where 子句。

我怎样才能正确地做到这一点?

最佳答案

您需要对您的条件进行分组。

->where('orders.date_paid', 'BETWEEN', array($from, $to))
->and_where_open()
->where('orders.status', '=', 'new')
->or_where('orders.status', '=', 'delivered')
->and_where_close();

关于Kohana 查询生成器 : and or where clause,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7987327/

相关文章:

php - Kohana 3.2 'advance' ORM加入

java - 如何在 Window Builder 中生成不同数量的文本框和标签

具有良好用户登录/管理的 PHP 框架

php - 模型中的 Kohana ORM 自定义方法

php - 科哈纳 3.1 ORM : Empty model property value saved as 0 (zero) instead of NULL

php - kohana 框架无法在 Linux 服务器上加载模块,而在 mamp 上完美加载模块

java - 在 Java 中创建嵌套的 Fluent API

java - 复杂构建器模式场景 - java

Flex 移动应用程序中的 iOS 7 操作栏外观

java - 使用父类的通用生成器创建子类