phpmysqlzend-frameworkpdozend-db-table

Zend Framework: Select with join and PDO name param binding


I am using Zend Framework and have been trying to do a joined query and also use named param binding. Referencing from the two posts below. When I just do the join everything works. When I add the name binding then it gets this error:

Message: SQLSTATE[HY093]: Invalid parameter number: no parameters were bound

How to do a joined query in the ZF tables interface?

Zend Framework: How to find a table row by the value of a specified column?

I have scaled it way down trying to remove any possible errors but it is still getting the error and no idea why.

$query = "country = :cc";  // changing :cc to 'US' everything works
$params = array(':cc' => 'US');

$db = $this->getDbTable();
$select = $db->select(Zend_Db_Table::SELECT_WITH_FROM_PART);

$select->setIntegrityCheck(false)
       ->join(array("daytable"), 'weektable.showid = daytable.id')
       ->where($query, $params);

$rowset = $db->fetchAll($select);

Solution

  • Try this:

    ->where('country = ?', 'US')
    

    Binding params with Zend_Db_Select