Example #1
0
 public function testHasRecursiveWithShortcutSyntax()
 {
     $qb = new QueryBuilder();
     $qb->setRoot('Blog')->whereHas('articles/readers')->get(['*'], false);
     $sql = 'SELECT `_`.* FROM `blogs` `_` WHERE EXISTS (SELECT `articles`.* FROM `articles` `articles` WHERE `articles`.`blog_id` = `_`.`id` AND EXISTS (SELECT `articles.readers`.* FROM `USERS` `articles.readers` INNER JOIN `articles_USERS` `articles.readers_m` ON `articles.readers`.`id` = `articles.readers_m`.`user_id` WHERE `articles.readers_m`.`article_id` = `articles`.`id`))';
     $val = [];
     $q = $qb->getQuery()->compile();
     $this->assertEquals($sql, $q->getSql());
     $this->assertEquals($val, $q->getValues());
 }