Hi,
We have a Document Management application. I have 5000 image files loaded in mysql DB. Need to delete them when the folder is deleted at the client.
Using the following code,
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;
}
The above function is called in a loop in this manner,
// 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);
}
This works perfectly when we delete,if the number of images in the DB is less then 500. If more, I am running into the dreaded, "Fatal error: Call to a member function prepare() on a non-object".
Please help.
Thanks
~Jad