我正在使用 Zend Framework,并一直在尝试执行连接查询并使用命名参数绑定。参考以下两篇文章。当我刚刚加入时,一切正常。当我添加名称绑定时,它会收到此错误:
消息:SQLSTATE[HY093]:参数号无效:没有参数 绑定
我已经缩小了它的规模,试图消除任何可能的错误,但它仍然出现错误,不知道为什么。
$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);
$query = "country = ?"; // changing :cc to 'US' everything works
$param = '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, $param);
$rowset = $db->fetchAll($select);
$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);
$select->bind($params);
$rowset = $db->fetchAll($select);