query($sql); if ($migrationEntries && $migrationEntries->num_rows > 0){ $migrationEntry=$migrationEntries->fetch_assoc(); $lastBatchNo=$migrationEntry["batch"]; echo "$filename exists (batch number $lastBatchNo)\n"; }else{ // create new record! $lastBatchNo++; $sql="INSERT INTO migrations(migration,batch) VALUES ('$filename',$lastBatchNo)"; $addEntry=$dbConnection->query($sql); if ($addEntry){ echo "$filename does NOT exist - added successfully with batch ID $lastBatchNo\n"; }else{ die("Error adding record for $filename"); } } } }else{ die("Error connecting to database with provided settings"); } }else{ die("Required database settings in .env could not be located"); } ?>