Zend Framework

quoteInto changes value when an array is passed as second argument.

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: N/A N/A
  • Resolution: Cannot Reproduce
  • Affects Version/s: 1.0.2
  • Fix Version/s: 1.9.3
  • Component/s: Zend_Db
  • Labels:
    None

Description

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.

Activity

Hide
Wil Sinclair added a comment -

Please categorize/fix as needed.

Show
Wil Sinclair added a comment - Please categorize/fix as needed.
Hide
Wil Sinclair added a comment -

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

Show
Wil Sinclair added a comment - This doesn't appear to have been fixed in 1.5.0. Please update if this is not correct.
Hide
Ralph Schindler added a comment -

Will evaluate within 2 weeks

Show
Ralph Schindler added a comment - Will evaluate within 2 weeks
Hide
Ralph Schindler added a comment -

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.

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()
     {
Show
Ralph Schindler added a comment - 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.
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()
     {

People

Vote (1)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: