public function testCountQuerySupportsIdentifierQuoting()
 {
     $q = new Doctrine_Query();
     $q->parseDqlQuery('SELECT u.name FROM User u INNER JOIN u.Phonenumber p');
     $this->assertEqual($q->getCountSqlQuery(), 'SELECT COUNT(*) AS "num_results" FROM (SELECT "e"."id" FROM "entity" "e" INNER JOIN "phonenumber" "p" ON "e"."id" = "p"."entity_id" WHERE ("e"."type" = 0) GROUP BY "e"."id") "dctrn_count_query"');
 }
Beispiel #2
0
 public function testAggregateFunctionsInOrderByAndHavingWithCount()
 {
     $q = new Doctrine_Query();
     $q->select('u.*, COUNT(a.id) num_albums')->from('User u')->leftJoin('u.Album a')->orderby('num_albums desc')->groupby('u.id')->having('num_albums > 0')->limit(5);
     try {
         $this->assertEqual($q->getCountSqlQuery(), 'SELECT COUNT(*) AS num_results FROM (SELECT e.id, COUNT(a.id) AS a__0 FROM entity e LEFT JOIN album a ON e.id = a.user_id WHERE e.type = 0 GROUP BY e.id HAVING a__0 > 0) dctrn_count_query');
         $q->count();
         $this->pass();
     } catch (Doctrine_Exception $e) {
         $this->fail($e->getMessage());
     }
 }