73 lines
1.6 KiB
PHP
73 lines
1.6 KiB
PHP
|
|
<?php
|
|
//document_revisions
|
|
$table = "punch_lists";
|
|
$mainPath = "009_Punch_List/";
|
|
$nullDownload = db($table);
|
|
$nullDownload = $nullDownload->get();
|
|
//dump($nullDownload->count());
|
|
|
|
DB::beginTransaction();
|
|
|
|
$say = 0;
|
|
$k = 0;
|
|
Log::debug("📄$table PDF Link to DB Start " . simdi());
|
|
try {
|
|
foreach($nullDownload AS $ne) {
|
|
$data = "{$ne->punch_list_no}";
|
|
$data = str_replace("/", "*", $data);
|
|
$data = str_replace(" ", "*", $data);
|
|
|
|
if(trim($data) != "") {
|
|
$path = "storage/documents/$mainPath/*$data*";
|
|
$searchPDF = glob($path);
|
|
|
|
|
|
$updateData = [];
|
|
|
|
$updateData['punch_list_download'] = null;
|
|
|
|
|
|
|
|
if(isset($searchPDF[0])) {
|
|
$updateData['punch_list_download'] = $searchPDF[0];
|
|
}
|
|
|
|
|
|
//dump($updateData);
|
|
|
|
db($table)
|
|
->where("id", $ne->id)
|
|
->update($updateData);
|
|
|
|
|
|
|
|
$k++;
|
|
|
|
|
|
|
|
if($say == $commitSize) {
|
|
DB::commit();
|
|
DB::beginTransaction();
|
|
$say = 0;
|
|
|
|
}
|
|
|
|
$say++;
|
|
}
|
|
|
|
|
|
}
|
|
DB::commit();
|
|
Log::debug("$table update PDF link for $k rows");
|
|
//dump("$table update PDF link for $k rows");
|
|
|
|
} catch (\Throwable $th) {
|
|
DB::rollback();
|
|
Log::error("not update PDF links " . $th->getMessage());
|
|
////dump($th->getMessage());
|
|
}
|
|
|
|
Log::debug("📄$table PDF Link to DB Finish " . simdi());
|
|
|
|
?>
|