Browse Source

ZF-5868
- Fixed the passing of bound params during execute() to profiler when added via bindValue() in statement

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@18078 44c647ce-9c0f-0410-b52a-842ac1e357ba

ralph 16 years ago
parent
commit
4954440080
2 changed files with 26 additions and 0 deletions
  1. 3 0
      library/Zend/Db/Statement/Pdo.php
  2. 23 0
      tests/Zend/Db/Statement/Pdo/TestCommon.php

+ 3 - 0
library/Zend/Db/Statement/Pdo.php

@@ -132,6 +132,9 @@ class Zend_Db_Statement_Pdo extends Zend_Db_Statement implements IteratorAggrega
         if (is_string($parameter) && $parameter[0] != ':') {
             $parameter = ":$parameter";
         }
+        
+        $this->_bindParam[$parameter] = $value;
+        
         try {
             if ($type === null) {
                 return $this->_stmt->bindValue($parameter, $value);

+ 23 - 0
tests/Zend/Db/Statement/Pdo/TestCommon.php

@@ -98,4 +98,27 @@ abstract class Zend_Db_Statement_Pdo_TestCommon extends Zend_Db_Statement_TestCo
             $this->assertType('PDOException', $e->getChainedException());
         }
     }
+    
+    /**
+     * 
+     * @group ZF-5868
+     */
+    public function testStatementWillPersistBindParamsInQueryProfilerAfterExecute()
+    {
+        $this->_db->getProfiler()->setEnabled(true);
+        $products = $this->_db->quoteIdentifier('zfproducts');
+        $product_id = $this->_db->quoteIdentifier('product_id');
+
+        $sql = "SELECT * FROM $products WHERE $product_id > :product_id ORDER BY $product_id ASC";
+        $stmt = $this->_db->prepare($sql);
+        $stmt->bindValue('product_id', 1);
+        $stmt->execute();
+        
+        $params = $this->_db->getProfiler()->getLastQueryProfile()->getQueryParams();
+
+        $target = array(':product_id' => 1);
+        $this->assertEquals($target, $params);
+        
+    }
+    
 }