gpt4 book ai didi

php - PDO_MYSQL : general error 2014

转载 作者:行者123 更新时间:2023-11-29 02:30:51 27 4
gpt4 key购买 nike

我正在从普通的 mysql_* 迁移到 PDO(是的,我知道日历上是 2012 年)。
我正在编写一个简单的包装类,以便有机会做类似的事情 $f=$db->FetchAll("SELECT * FROM...")在我的网站上。这是我正在做的:

    public function Query($q, $errmessage="", $params=array()) {
try {
$stmt=$this->connect->prepare($q);
if (is_array($params) && count($params)>0) {
$stmt->execute($params);
} else {
$stmt->execute();
}
return $stmt;
} catch(PDOException $e) {
die($errmessage.": ".$e->GetMessage());
}
}

public function Fetch($q, $arraylist=0) {
if (!is_object($q)) { // Assuming it's a raw query
$stmt=$this->Query($q, "Unable to process the query for fetching");
} else $result=$q;
$f=$stmt->Fetch();
return $f;
}

这会引发“2014 年一般错误”异常。
任何帮助表示赞赏。
谢谢!

最佳答案

2014 不是年份,是错误代码。尝试 googling the error下次。

$pdo->query("INSERT INTO test (some) VALUES ('1111111111111111'), ('1111111111111'); -- I AM AN SQL COMMENT, REMOVING ME WILL SOLVE THIS PROBLEM");

Due to the ";" this is a multi-statement, executing two queries while the second is only a comment. The second "result" can be accessed using PDOStatement->nextRowset. [source]

或:

After spending hours trying to track down why we were getting this error on a new server, after the same code ran fine on other servers, we found the problem to be an old MySQL client library running on our web server, and a latest-version MySQL server running on the database server's box. [source]

关于php - PDO_MYSQL : general error 2014,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13406862/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com