How to use the between clause in Kohana ORM

I'm new to Kohana I'm using ORM to get data

I want to build a query where the between clause exists as follows

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)

Because I'm 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 got such a query

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)

One can point out how to use the between clause

Solution

I think you should use or_ where(‘events.eventstart’,’BETWEEN’,array($from,$to));

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>