Changeset 4519

Show
Ignore:
Timestamp:
06/13/08 18:01:31 (13 months ago)
Author:
jwage
Message:

fixes #1133

Location:
branches/0.11
Files:
1 added
2 modified

Legend:

Unmodified
Added
Removed
  • branches/0.11/lib/Doctrine/Query.php

    r4491 r4519  
    17471747 
    17481748    /** 
    1749      * count 
    1750      * fetches the count of the query 
    1751      * 
    1752      * This method executes the main query without all the 
    1753      * selected fields, ORDER BY part, LIMIT part and OFFSET part. 
    1754      * 
    1755      * Example: 
    1756      * Main query: 
    1757      *      SELECT u.*, p.phonenumber FROM User u 
    1758      *          LEFT JOIN u.Phonenumber p 
    1759      *          WHERE p.phonenumber = '123 123' LIMIT 10 
    1760      * 
    1761      * The modified DQL query: 
    1762      *      SELECT COUNT(DISTINCT u.id) FROM User u 
    1763      *          LEFT JOIN u.Phonenumber p 
    1764      *          WHERE p.phonenumber = '123 123' 
    1765      * 
    1766      * @param array $params        an array of prepared statement parameters 
    1767      * @return integer             the count of this query 
    1768      */ 
    1769     public function count($params = array()) 
     1749     * Get count sql query for this Doctrine_Query instance 
     1750     * Used in Doctrine_Query::count() for returning an integer for the number of records which will 
     1751     * be returned when executed. 
     1752     * 
     1753     * @return string $q 
     1754     */ 
     1755    public function getCountQuery() 
    17701756    { 
    17711757        // triggers dql parsing/processing 
     
    18171803        $q .= ( ! empty($having)) ? ' HAVING ' . implode(' AND ', $having): ''; 
    18181804 
     1805        return $q; 
     1806    } 
     1807 
     1808    /** 
     1809     * count 
     1810     * fetches the count of the query 
     1811     * 
     1812     * This method executes the main query without all the 
     1813     * selected fields, ORDER BY part, LIMIT part and OFFSET part. 
     1814     * 
     1815     * Example: 
     1816     * Main query: 
     1817     *      SELECT u.*, p.phonenumber FROM User u 
     1818     *          LEFT JOIN u.Phonenumber p 
     1819     *          WHERE p.phonenumber = '123 123' LIMIT 10 
     1820     * 
     1821     * The modified DQL query: 
     1822     *      SELECT COUNT(DISTINCT u.id) FROM User u 
     1823     *          LEFT JOIN u.Phonenumber p 
     1824     *          WHERE p.phonenumber = '123 123' 
     1825     * 
     1826     * @param array $params        an array of prepared statement parameters 
     1827     * @return integer             the count of this query 
     1828     */ 
     1829    public function count($params = array()) 
     1830    { 
     1831        $q = $this->getCountQuery(); 
     1832 
    18191833        if ( ! is_array($params)) { 
    18201834            $params = array($params); 
    18211835        } 
    18221836 
    1823         // append parameters 
    1824         $params = array_merge($this->_params['where'], $this->_params['having'], $this->_params['join'], $params); 
     1837        $params = array_merge($this->_params['join'], $this->_params['where'], $this->_params['having'], $params); 
    18251838 
    18261839        $params = $this->convertEnums($params); 
  • branches/0.11/tests/run.php

    r4517 r4519  
    8080$tickets->addTestCase(new Doctrine_Ticket_1134_TestCase()); 
    8181$tickets->addTestCase(new Doctrine_Ticket_1118_TestCase()); 
     82$tickets->addTestCase(new Doctrine_Ticket_1133_TestCase()); 
    8283 
    8384$test->addTestCase($tickets);