Changeset 4488

Show
Ignore:
Timestamp:
06/08/08 17:59:34 (13 months ago)
Author:
guilhermeblanco
Message:

Fixes 1116. Actually it is a PHP bug that was only solved in 6 march 2008. So only possible release to have this fixed is using PHP 5.2.6. Please refer to  http://bugs.php.net/bug.php?id=40417 for more explanation. I updated the test case to be sure we are correctly passing things to MySQL. Updated Query and QueryAbstract? to use getParams as they should. Also, getParams only displays the correct number of params after preQuery event. SoftDelete? binds new values only after processing DQL (which is done calling getSql()), so getParams only has the right values after it.

Location:
branches/0.11
Files:
3 modified

Legend:

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

    r4478 r4488  
    288288    } 
    289289 
    290     /** 
    291      * getParams 
    292      * 
    293      * @return array 
    294      */ 
    295     public function getParams() 
    296     { 
    297         return array_merge($this->_params['join'], $this->_params['set'], $this->_params['where'], $this->_params['having']); 
    298     } 
    299  
    300     /** 
    301      * setParams 
    302      * 
    303      * @param array $params 
    304      */ 
    305     public function setParams(array $params = array()) { 
    306         $this->_params = $params; 
    307     } 
    308290 
    309291    /** 
  • branches/0.11/lib/Doctrine/Query/Abstract.php

    r4478 r4488  
    501501 
    502502    /** 
     503     * getParams 
     504     * 
     505     * @return array 
     506     */ 
     507    public function getParams($params = array()) 
     508    { 
     509        return array_merge($this->_params['join'], $this->_params['set'], $this->_params['where'], $this->_params['having'], $params); 
     510    } 
     511 
     512    /** 
     513     * setParams 
     514     * 
     515     * @param array $params 
     516     */ 
     517    public function setParams(array $params = array()) { 
     518        $this->_params = $params; 
     519    } 
     520 
     521    /** 
    503522     * setView 
    504523     * sets a database view this query object uses 
     
    968987        } 
    969988 
    970         $params = array_merge($this->_params['join'], 
    971                               $this->_params['set'], 
    972                               $this->_params['where'], 
    973                               $this->_params['having'], 
    974                               $params); 
     989        $params = $this->getParams($params); 
    975990 
    976991        if ($this->_resultCache && $this->_type == self::SELECT) { 
  • branches/0.11/tests/Ticket/1116TestCase.php

    r4486 r4488  
    77                $this->dbh = new Doctrine_Adapter_Mock('mysql'); 
    88                //$this->dbh = new PDO("mysql:host=localhost;dbname=testing", 'root', 'password'); 
    9                    
     9 
    1010                $this->conn = Doctrine_Manager::getInstance()->openConnection($this->dbh); 
    1111                $this->conn->export->exportClasses(array('Ticket_1116_User')); 
    1212        } 
     13 
     14 
    1315        public function testTicket() 
    1416        { 
     
    1719                  ->from('Ticket_1116_User s') 
    1820                  ->where('s.username = ?', array('test')); 
    19                    
     21 
    2022                // to see the error switch dbh to a real db, the next line will trigger the error 
    2123                $test = $q->fetchOne();  //will only fail with "real" mysql  
    22                 $this->assertFalse($test);                 
    23                            
     24                $this->assertFalse($test); 
     25 
    2426                $sql    = $q->getSql(); // just getSql()?!?! and it works ? the params are ok after this call   
    25                 $params = $q->getParams();        
    26                 $this->assertEqual(count($params),2); // now we have array('test',null) very strange .....  
    27                   
     27                $params = $q->getParams(); 
     28                $this->assertEqual(count($params), 2); // now we have array('test',null) very strange .....  
     29 
     30                $this->assertEqual($sql, "SELECT u.id AS u__id, u.username AS u__username, u.deleted AS u__deleted FROM user u WHERE u.username = ? AND u.deleted = ?"); 
     31                $this->assertEqual($params, array('test', false)); 
     32 
    2833                //now also this works! (always works witch mock only fails with mysql) 
    2934                $test = $q->fetchOne(); 
    30                 $this->assertFalse($test);            
     35                $this->assertFalse($test); 
    3136        } 
    3237} 
    3338 
     39 
    3440class Ticket_1116_User extends Doctrine_Record 
    3541{ 
    36   public function setTableDefinition() 
     42        public function setTableDefinition() 
    3743        { 
    3844                $this->setTableName('user'); 
     
    4046                $this->hasColumn('username', 'string', 255); 
    4147        } 
     48 
     49 
    4250        public function setUp() 
    4351        {