Invalid bind-variable name in Zend framework with Mysqli
I was working on a application with Zend Framework and PDO_MYSQL Adapter.
But my client server doesnt support PDO_MYSQL
I changed the开发者_运维技巧 adapter to Mysqli and I'm getting this error:
Invalid bind-variable name
How to resolve it?
Unfortunately MySQLi doesn't actually support named parameters, but the Exception message isn't really clear on that, despite being thrown in this block of code:
if ($this->_adapter->supportsParameters('named') === false) {
/**
* @see Zend_Db_Statement_Exception
*/
require_once 'Zend/Db/Statement/Exception.php';
throw new Zend_Db_Statement_Exception("Invalid bind-variable name '$val'");
}
The Exception should really say:
You are trying to use named parameters with an adapter that doesn't support them
The solution is easy, just switch your adapter from Mysqli to Pdo_Mysql.
Reference.
精彩评论