생성은 됐습니다!!!
이제 if문에 조건을 줘야하는데 몽고디비 조회 값이 없을때만 사용해야합니다
// read all records
$filter = ['model_code' => ['$regex' => '^'.$model_code.'$', '$options' => 'i']];
$option = ['limit' => 1];
$read = new MongoDB\Driver\Query($filter, $option);
//fetch records
$records = $conn->executeQuery("$dbname.$collection", $read);
echo json_encode(iterator_to_array($records), JSON_UNESCAPED_UNICODE);
if(???????) {
$dir = "/var/www/html/estimate/log". date('Y/n/d');
if(!is_dir($dir))
{
mkdir($dir,0777,true);
chmod($dir,0777,true);
}
$log_txt = date('Y_m_d_H:i:s') . ' | '. '검색모델명'. ' : '.$model_code;
$log_dir = $dir."/";
$file_name = date('Y_m_d');
$log_file = fopen($log_dir."/".$file_name.".txt", "a");
fwrite($log_file, $log_txt."\r\n");
fclose($log_file);
}