示例#1
0
 public function testSubQueryWithoutAliasRecursive()
 {
     $c1 = new BookQuery();
     $c2 = new BookQuery();
     $c2->addSelectQuery($c1);
     // no alias
     $c2->filterByPrice(20, Criteria::LESS_THAN);
     $c3 = new BookQuery();
     $c3->addSelectQuery($c2);
     // no alias
     $c3->filterByTitle('War%');
     $sql = "SELECT alias_2.ID, alias_2.TITLE, alias_2.ISBN, alias_2.PRICE, alias_2.PUBLISHER_ID, alias_2.AUTHOR_ID FROM (SELECT alias_1.ID, alias_1.TITLE, alias_1.ISBN, alias_1.PRICE, alias_1.PUBLISHER_ID, alias_1.AUTHOR_ID FROM (SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID FROM `book`) AS alias_1 WHERE alias_1.PRICE<:p2) AS alias_2 WHERE alias_2.TITLE LIKE :p1";
     $params = array(array('table' => 'book', 'column' => 'TITLE', 'value' => 'War%'), array('table' => 'book', 'column' => 'PRICE', 'value' => 20));
     $this->assertCriteriaTranslation($c3, $sql, $params, 'addSelectQuery() forges a unique alias if none is given');
 }
 public function testSubQueryWithoutAliasRecursive()
 {
     $c1 = new BookQuery();
     $c2 = new BookQuery();
     $c2->addSelectQuery($c1);
     // no alias
     $c2->filterByPrice(20, Criteria::LESS_THAN);
     $c3 = new BookQuery();
     $c3->addSelectQuery($c2);
     // no alias
     $c3->filterByTitle('War%');
     $sql = "SELECT alias_2.id, alias_2.title, alias_2.isbn, alias_2.price, alias_2.publisher_id, alias_2.author_id FROM (SELECT alias_1.id, alias_1.title, alias_1.isbn, alias_1.price, alias_1.publisher_id, alias_1.author_id FROM (SELECT book.id, book.title, book.isbn, book.price, book.publisher_id, book.author_id FROM `book`) AS alias_1 WHERE alias_1.price<:p2) AS alias_2 WHERE alias_2.title LIKE :p1";
     $params = array(array('table' => 'book', 'column' => 'title', 'value' => 'War%'), array('table' => 'book', 'column' => 'price', 'value' => 20));
     $this->assertCriteriaTranslation($c3, $sql, $params, 'addSelectQuery() forges a unique alias if none is given');
 }