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());
}
}
From my testing this seems to be an issue with PDO and the way the execute wrapper is defined:
<?
/**
*
*/
public function execute(array $params = array())
?>
if you execute the object without any parameters to the Zend execute method:
$stmt->execute()
$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.
- Executes a prepared statement.
*
- @param array $params OPTIONAL Values to bind to parameter placeholders.
- @return bool
- @throws Zend_Db_Statement_Exception
*/
public function execute(array $params = array())
Unknown macro: { try {
return $this->_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: $stmt->execute() $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.