public function restrictionsFactory() { $job_id = Job::column('job_id'); $c = new Criteria(Restrictions::anyOf(Restrictions::not($job_id->in(array(1, 2, 3))), Restrictions::allOf(Job::column('title')->like('Hello%'), Job::column('valid_from')->greaterThan(new \util\Date('2006-01-01'))), Restrictions::allOf(Restrictions::like('title', 'Hello%'), Restrictions::greaterThan('valid_from', new \util\Date('2006-01-01'))), $job_id->between(1, 5))); $this->assertSql('where (not (job_id in (1, 2, 3))' . ' or (title like "Hello%" and valid_from > "2006-01-01 12:00AM")' . ' or (title like "Hello%" and valid_from > "2006-01-01 12:00AM")' . ' or job_id between 1 and 5)', $c); }