Hi gAMBOOKa
Why do you want to insert all records with a single statement? You could use a prepared statement:
INSERT INTO multimedia (filename, regex, flag) VALUES (?, ?, ?);
and a for-loop to insert the records one by one.
I'm not a PHP programmer, but the code could look like this (parts taken from http://php.net/manual/en/pdo.prepared-statements.php):
$stmt = $dbh->prepare("INSERT INTO multimedia (filename, regex, flag) VALUES (:filename, :regex, :flag)");
$stmt->bindParam(':filename', $filename);
$stmt->bindParam(':regex', $regex);
$stmt->bindParam(':flag', $flag);
for ( $i = 1; $i <= ...; $i++) {
$filename = ...
$regex = ...
$flag = ...
$stmt->execute();
}
Using a prepared statement, the DBMS only compiles the SQL once, as it would with your SQL statement. To get sure that either all or no records are inserted (if you need such an assertion anyway), use a transaction.
Further, this would also solve your escaping problem, since you don't need to put the values in a string. The string for a prepared statement only defines the SQL "template".