如何在 Kohana ORM 中使用 BETWEEN 子句
我是科哈纳的新手。我正在使用 ORM 来获取数据。
我想构建一个查询,其中存在 BETWEEN
子句。如下所示
SELECT `rooms`.* FROM `rooms` LEFT JOIN `events` ON (`rooms`.`id` = `events`.`room_id`)
WHERE `events`.`room_id` IS NULL
OR (`events`.`eventstart` NOT BETWEEN 1312210800 AND 1312218000)
,我正在执行以下操作
$rooms = $room->join('events', 'LEFT')
->on('rooms.id', '=', 'events.room_id')
->where('events.room_id', 'IS', NULL)
->and_where_open()
->or_where('events.eventstart' , 'NOT BETWEEN', $from)
->and_where_close()
->find_all();
,但我收到这样的查询
SELECT `rooms`.* FROM `rooms` LEFT JOIN `events` ON (`rooms`.`id` = `events`.`room_id`)
WHERE `events`.`room_id` IS NULL AND (`events`.`eventstart` NOT BETWEEN 1312210800)
有人能指出如何使用 BETWEEN 子句吗
I am new to kohana. I am using ORM for getting data.
I want to build a query in which BETWEEN
clause is there. as following
SELECT `rooms`.* FROM `rooms` LEFT JOIN `events` ON (`rooms`.`id` = `events`.`room_id`)
WHERE `events`.`room_id` IS NULL
OR (`events`.`eventstart` NOT BETWEEN 1312210800 AND 1312218000)
for that i am doing the following
$rooms = $room->join('events', 'LEFT')
->on('rooms.id', '=', 'events.room_id')
->where('events.room_id', 'IS', NULL)
->and_where_open()
->or_where('events.eventstart' , 'NOT BETWEEN', $from)
->and_where_close()
->find_all();
But i am getting the the query like this
SELECT `rooms`.* FROM `rooms` LEFT JOIN `events` ON (`rooms`.`id` = `events`.`room_id`)
WHERE `events`.`room_id` IS NULL AND (`events`.`eventstart` NOT BETWEEN 1312210800)
Can someone point out how to use BETWEEN clause
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
发布评论
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
我认为你应该使用 or_where('events.eventstart', 'BETWEEN', array($from, $to));
有关 Kohana Query Builder 的文档可以在这里找到 -> http://kohanaframework.org/3.2/guide/database/query/builder
ORM 使用查询生成器。
I think you should use
or_where('events.eventstart', 'BETWEEN', array($from, $to));
Documentation on Kohana Query Builder can be found here -> http://kohanaframework.org/3.2/guide/database/query/builder
ORM uses Query Builder.