我正在尝试在MySQL服务器上执行预准备语句,我正在生成Insert,Update和Select查询并在服务器上运行它。 更新查询失败,没有错误(将rowCount()返回为零)但Insert ans Select成功。 但是当我用它的值替换paramValue并在MySQL上运行它的成功
public function __connectToDB() {
try {
$this->__connection = new PDO ( "mysql:host=localhost;dbname=spatim-user", DATABASE_USERNAME, DATABASE_PASSWORD );
$this->__connection->setAttribute ( PDO::ATTR_EMULATE_PREPARES, false );
$this->__connection->setAttribute ( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
} catch ( PDOException $e ) {
die ( "connection failed: " . $e->getMessage () );
}
}
try {
$this->__connectToDB ();
$stmt = $this->__connection->prepare("UPDATE `user-flags` SET `profile-configured`=':set_profile_configured' WHERE `user-id`=':get_user_id';");
if($stmt->execute(array("set_profile_configured" => "1", "get_user_id" => "58325edf7998c")) !== true) {
return false;
}
return $stmt->rowCount();
} catch ( PDOException $e ) {
return false;
}
这是我传递的SQL命令和参数: