views:

140

answers:

1

Hi all,

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 im getting

Invalid bind-variable name

error.

How to resolve it thanks in advance.

Regards Nizam

+1  A: 

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.

St.Woland
Oh! but the customer needs to agree to change the server he has...Is there any solution to work with out named parameters?
Nizam
Either change your code not to use named parameters, or simply configure your application to use pdo_mysql extension instead of mysqli.
St.Woland
To clarify: switching from `MySQLi` to `Pdo_Mysql` would only require a change on the PHP side if PHP doesn't have it compiled in or loaded as a module. It doesn't require a change on the MySQL server side.
awgy