roast_soul
roast_soul

Reputation: 3650

Zend Framework Error:Invalid parameter number: no parameters were bound'

I'm using the Zend Frameworker 1.12.

According to the help file, I used the Zend_Db_Statement to execute my sql.

Below is my php code:

 $sql = "delete from options where id=?";
 $stmt = new Zend_Db_Statement_Mysqli($this->getAdapter(), $sql);
 return $stmt->execute(array('1'));

But the error is exception 'PDOException' with message 'SQLSTATE[HY093]: Invalid parameter number: no parameters were bound' in D:\Zend\workspaces\DefaultWorkspace.metadata.plugins\org.zend.php.framework.resource\resources\ZendFramework-1\library\Zend\Db\Statement\Mysqli.php:209 Stack trace:

......... .........

I googled for days, but nothing works.

Any one know how to fix it?

Upvotes: 0

Views: 1631

Answers (2)

Tomas Creemers
Tomas Creemers

Reputation: 2715

The code uses the class Zend_Db_Statement_Mysqli but your connection is not a 'mysqli' connection. It is a Pdo_Mysql connection. This causes the code to fail. You can fix your code by replacing Zend_Db_Statement_Mysqli with Zend_Db_Statement_Pdo. However, a better solution would be the following:

$sql = "delete from options where id=?";
$this->getAdapter()->query($sql, array('1'));

This should automatically use the correct classes (regardless of the type of your database connection) and will take care of different steps internally.

Upvotes: 5

romik
romik

Reputation: 630

$sql = "delete from options where id=?";
$stmt = new Zend_Db_Statement_Mysqli($this->getAdapter(), $sql);
return $stmt->execute(array(1 => '1'));

Upvotes: -1

Related Questions