/** * @test */ public function shouldCreateProperSql() { //given $restriction = Restrictions::greaterThan(5); //when $sql = $restriction->toSql('key'); //then $this->assertEquals('key > ?', $sql); $this->assertEquals(array(5), $restriction->getValues()); }
/** * @return Event[] */ public static function loadNew() { $lastEventId = Session::get('last_event_id'); if (!$lastEventId) { //do not load events that we triggered before this session was started /** @var Event $lastEvent */ $lastEvent = Event::queryBuilder()->limit(1)->order('id desc')->fetch(); Session::set('last_event_id', $lastEvent ? $lastEvent->id : 0); } $events = Event::where(['id' => Restrictions::greaterThan($lastEventId)])->order('id asc')->fetchAll(); if ($events) { Session::set('last_event_id', Arrays::last($events)->id); } return $events; }