ZF-2018: getQueryParams() returns wrong array
Description
Consider the following snippet:
$params = array (
'host' => 'localhost',
'username' => 'user',
'password' => 'pass',
'dbname' => 'test',
'profiler' => true
);
$db = Zend_Db::factory('PDO_MYSQL', $params);
$query = "SELECT * FROM table WHERE field1 = ? AND field2 = ?";
$stmt = $db->query(
$query,
array(
'value1',
'value2'
)
);
$profiler = $db->getProfiler();
$profile = $profiler->getLastQueryProfile();
var_dump($profile->getQueryParams());
The output of the var_dump will be: array(2) { [1]=> string(4) "value2" [2]=> string(4) "value2" }
Whereas the first value should be value1, not value2. I've tested it with bigger arrays too and in every testcase the whole array is filled with the value of the last item.
Even though getQueryParams returns the wrong values, he values are correctly inserted into the prepared-statement.
Although it's only a minor loss of functionality, I put Major as the priority because there is no easy workaround. At least, i don't know any way to find out which values have been given to the prepared statement without this function.
Comments
Posted by Thomas Weidner (thomas) on 2007-10-01T12:25:54.000+0000
Assigned to Bill
Posted by Wil Sinclair (wil) on 2008-03-21T17:05:33.000+0000
This issue should have been fixed for the 1.5 release.
Posted by Wil Sinclair (wil) on 2008-03-25T20:43:57.000+0000
Please categorize/fix as needed.
Posted by Wil Sinclair (wil) on 2008-04-18T13:11:54.000+0000
This doesn't appear to have been fixed in 1.5.0. Please update if this is not correct.
Posted by Mickael Perraud (mikaelkael) on 2008-09-13T00:34:43.000+0000
Cannot reproduce with the same piece of code. Probably corrected by SVN6163 and SVN6170 even if it were not the initial goal.