我們有一個文檔管理應用程序。我在MySQL DB中加載了5000個圖像文件。在客戶端刪除文件夾時需要刪除它們。致命錯誤:調用成員函數prepare()在非對象上
使用下面的代碼,
public function delete($dbh){
$sql = "DELETE FROM fileTable WHERE FID=:fid;
DELETE FROM file_blobTable WHERE FID=:fid";
$stmt = $dbh -> prepare($sql);
$stmt -> bindParam(":fid", $this->fid, PDO::PARAM_INT);
$this -> fdid = -1; //
if ($stmt -> execute()) {
return 0;
}
return 1;
}
上述函數被調用以這種方式循環,
// Loop through the folder and delete all the files it contains.
foreach ($files as $fileID) {
// Get DB handle
$dbh1 = DB::getWriteDB();
$f = new File($fileID);
$f -> delete($dbh1);
}
這工作完全當我們刪除,如果在數據庫中的圖像數量小於500. 如果更多,我遇到了可怕的,
"Fatal error: Call to a member function prepare() on a non-object".