ZF-1440: Binding parameters and results to PHP variables is broken

Issue Type: Bug Created: 2007-05-27T18:10:31.000+0000 Last Updated: 2007-07-05T14:44:13.000+0000 Status: Resolved Fix version(s): - 1.0.0 RC2 (08/Jun/07)

Reporter: Bill Karwin (bkarwin) Assignee: Bill Karwin (bkarwin) Tags: - Zend_Db

Related issues: - ZF-1475



The function bindParam(), bindValue(), and bindColumn() need some bugfixing. These are not working with any Zend_Db adapters currently.


Posted by Jeffrey Sambells (jeffrey) on 2007-05-29T12:10:04.000+0000

From my testing this seems to be an issue with PDO and the way the execute wrapper is defined:

\_stmt->execute($params); } catch (PDOException $e) { require\_once 'Zend/Db/Statement/Exception.php'; throw new Zend\_Db\_Statement\_Exception($e->getMessage()); } } ?> if you execute the object without any parameters to the Zend execute method:


$params is assigned an empty array. PDO them seems to use this empty array rather than the parameters from bindParam etc. if you change the function declaration to:

public function execute(array $params = null)

everything begins to work again as without an input it now passes NULL to the PDO execute method rather than an empty array.

Posted by Jeffrey Sambells (jeffrey) on 2007-05-29T12:25:19.000+0000

Also, the default NULL values for $type in bindValue() (and possibly others) is also causing issues:

public function bindValue($parameter, $value, $type = null)

If you bind a value without specifying the $type with a PDO::PARAM_* value then the value becomes null when executed.

I suggest changing it to:

public function bindValue($parameter, $value, $type = null) { if (is_string($parameter) && $parameter[0] != ':') { $parameter = ":$parameter"; } try { if(is_null($type)) { return $this->_stmt->bindValue($parameter, $value); } return $this->_stmt->bindValue($parameter, $value, $type); } catch (PDOException $e) { require_once 'Zend/Db/Statement/Exception.php'; throw new Zend_Db_Statement_Exception($e->getMessage()); } }

Posted by Bill Karwin (bkarwin) on 2007-05-29T13:36:35.000+0000

Thanks for the help debugging, Jeffrey! That did it -- at least for PDO adapters.

The fixes you suggest have been committed in revision 5048.

I'm going to leave this issue open for now, because I'd like to get it working across all adapters.

Posted by Bill Karwin (bkarwin) on 2007-06-08T20:58:41.000+0000

This fix was included in 1.0.0 RC2, at least for PDO adapters.

I have opened ZF-1475, ZF-1476, ZF-1477 for these binding features in IBM DB2, Oracle, and Mysqli.

Posted by Bill Karwin (bkarwin) on 2007-06-08T20:59:04.000+0000

Link to ZF-1475.

Posted by Bill Karwin (bkarwin) on 2007-06-08T20:59:18.000+0000

Link to ZF-1476.

Posted by Bill Karwin (bkarwin) on 2007-06-08T20:59:30.000+0000

Link to ZF-1477.

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.