“SQLSTATE [HY093]:参数号无效”PDO

时间:2015-02-03 07:53:40

标签: php mysql pdo

我有这个查询

$selectQuery = "SELECT * FROM daily_table WHERE date = :date AND event_type = :event_type AND product_type = :product_type";

$selectStatement = $db ->prepareQuery($selectQuery);

我需要在像

这样的循环中执行它
foreach ($tokenActivity as $activity) {

    $tokenActivityData = array(
                            "date"=>$activity['activity_date'],
                            "event_type"=>$activity['event_type'],
                            "product_type"=>$activity['product_type']
                         );

    $dataExists = $selectStatement->executeQuery($tokenActivityData);

    var_dump($dataExists);
}

现在这给了我错误

string(41) "SQLSTATE[HY093]: Invalid parameter number"

executeQuery是我的包装函数,它包含

//execute the statement
public function executeQuery($values) 
{
    try {

        if(empty($values)) {
            $res = $this->stmnt->execute(); 
        } else {
            $res = $this->stmnt->execute($values);
        }

        } catch (PDOException $e) {
            return $e->getMessage();
        }

        return $res;
}

0 个答案:

没有答案