ZF-2298: quoteInto changes value when an array is passed as second argument.

Issue Type: Bug Created: 2007-12-12T10:28:30.000+0000 Last Updated: 2009-08-27T10:20:20.000+0000 Status: Resolved Fix version(s): - 1.9.3 (22/Sep/09)

Reporter: Jason Austin (jfaustin) Assignee: Ralph Schindler (ralph) Tags: - Zend_Db

Related issues: Attachments:


When passing an array to $adapter->quoteInto() as the second argument, the function changes the values of the array. For example:

// names = Array ( [0] => php [1] => google [2] => working ) $names = array( 'php', 'google', 'working' );

$where = $dba->quoteInto('name IN (?)', $names)

// print the existing array print_r($names);

// prints out // Array ( [0] => 'php' [1] => 'google' [2] => 'working' )

Notice quoteInto() has now added single quotes to each value in the array, which is unexpected behavior. This was specifically recreated using the MySQL db adapter using Zend _Db_Table.


Posted by Wil Sinclair (wil) on 2008-03-25T20:44:00.000+0000

Please categorize/fix as needed.

Posted by Wil Sinclair (wil) on 2008-04-18T13:12:05.000+0000

This doesn't appear to have been fixed in 1.5.0. Please update if this is not correct.

Posted by Ralph Schindler (ralph) on 2009-01-10T10:58:52.000+0000

Will evaluate within 2 weeks

Posted by Ralph Schindler (ralph) on 2009-08-27T10:20:19.000+0000

Cannot reproduce, with latest trunk I tried the unit test below, and it passed fine. Appears that everything that is passed into quoteInto() comes out as it went in.

<pre class="highlight">
Index: tests/Zend/Db/Adapter/TestCommon.php
--- tests/Zend/Db/Adapter/TestCommon.php    (revision 17795)
+++ tests/Zend/Db/Adapter/TestCommon.php    (working copy)
@@ -1265,6 +1265,14 @@
         $this->assertEquals('foo = 1234 and bar = ?', $value,
             'Incorrect quoteInto() result for count');
+    public function testAdapterQuoteIntoArray()
+    {
+        $preNames = array('php', 'google', 'working');
+        $postNames = $preNames;
+        $where = $this->_db->quoteInto('IN (?)', $postNames);
+        $this->assertEquals($preNames, $postNames);
+    }
     public function testAdapterQuoteTypeInt()

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.