我有函数query和buildQueryParams
public function query($sql, $param = []) {
$q = self::$connectionInstance->prepare($sql);
if(is_array($param) && $param) {
$q->execute($param);
}
else {
$q->execute();
}
return $q;}
public function buildQueryParams($params = []) {
$default = [
"select" => "*",
"where" => "",
"other" => "",
"params" => "",
"filed" => "",
"value" => [],
"join" => ""
];
$this->queryParams = array_merge($default,$params);
return $this; }
我上课
$user = new apps_libs_useridentity();
$router = new apps_libs_router();
$categories = new apps_models_categories();
$id = intval($router->getGET("id"));
我有代码更新并从value中插入值
if($router->getPOST("submit") && $router->getPOST("name")) {
$params = [
":name" => $router->getPOST("name"),
];
$result = FALSE;
if($id) {
$params[":id"] = $id;
$result = $categories->buildQueryParams([
"value" => "name=:name",
"where" => "id=:id",
"params" => $params
])->update();
} else {
$result = $categories->buildQueryParams([
"field" => "(name,created_by,created_time) VALUES (?,?,now())",
"value" => [$params[":name"], $user->getId()]
])->insert();
}
当我运行程序时,我得到了错误:
(!)致命错误:C:\ wamp64 \ www \ Learning PHP \ apps \ libs \ DbConnection.php中的消息“ SQLSTATE [HY093]:无效的参数编号:未绑定任何参数”的未捕获异常“ PDOException”第51行
查询函数和buildQueryParams函数位于DbConnection.php文件中
我找不到问题!请告诉我问题出在哪里
谢谢!