my script is that. It compare files in a folder to files in database. If one file in my folder is not in my database, it inserts it. Now I would like to add a functionalit to compare the modified date of the file. If it has been modified, I insert it, and if not, just do nothing.
I tried to do something, but not sure how to make it.
bellow my script
$bdd = new PDO('mysql:host=localhost;dbname=check', 'root', 'root');
$dirname = './check/';
$dir = scandir($dirname);
$fichiers_bdd = $bdd->query("SELECT filename, modifiedDate1 FROM file");
$fichiers_bdd = $fichiers_bdd->fetchAll(PDO::FETCH_COLUMN);
$params = array();
$i = 0;
foreach($dir as $file) {
if($file != '.' && $file != '..' && !is_dir($dirname.$file) && !in_array($file, $fichiers_bdd))
{
if($i == 0){
$req="INSERT INTO file (filename, modifiedDate1) VALUES";
$i++;
}else $req .=", ";
$req .= "(?, '$modifiedDate1')";
$params[] = $file;
var_dump($req);
}
}
if(!empty($params)){
$stmt = $bdd->prepare($req);
$stmt->execute($params);
}else echo "all files are already in database.";