我有一个脚本可以自动更新一些用户信息。这是我用来更新数据库的部分。变量已定义且有效。
try {
$MyDBConn = new PDO("mysql:host=localhost;port=3306;dbname=$MyDBName", $MyDBUser, $MyDBPass);
// PDO can throw exceptions rather than Fatal errors, so let's change the error mode to exception
$MyDBConn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$MySQL = "UPDATE jos_jsn_users SET grading = '$MyFLTTRanking' WHERE fltt_license like '%$MyFLTTLicense'";
$MyStmt = $MyDBConn->prepare($MySQL);
$MyStmt->exec(); //error is here
$MySQL = "UPDATE jos_jsn_users SET grading_points = '$MyFLTTRankingPoints' WHERE fltt_license like '%$MyFLTTLicense'";
$MyStmt = $MyDBConn->prepare($MySQL);
$MyStmt->exec();
$MyDBConn = null;
// $output = shell_exec($MyWorkDir."bin/dbupdate_users.sh $MyFLTTLicense $MyFLTTRanking $MyFLTTRankingPoints");
}
catch(PDOException $e) {
echo "Connection failed: " . $e->getMessage()."\n";
}
当我运行脚本时,我收到此错误:
PHP致命错误:未捕获错误:调用未定义的方法PDOStatement :: exec()..#0 {main}抛出(文件)
亚麻布指向第一个陈述$MyStmt->exec();
我错在哪里或哪里?