mysql
// -----------------------------------------------------
$filename ='./themes/dumpTheme/dump-' .$nomTableCibleCss. '.sql';
$handle = fopen($filename, "r");
$indexBuffer = fread($handle, filesize($filename));
fclose($handle);
// Read in entire file
$lines = file($filename);
foreach ($lines as $line) {
if($continuer==true) {
// Skip it if it's a comment
if (substr($line, 0, 2) == '--' || $line == '') { continue; }
// Add this line to the current segment
$templine .= $line;
// If it has a semicolon at the end, it's the end of the query
if (substr(trim($line), -1, 1) == ';') {
// Perform the query
try {
if (!$idPdo->query($templine)) {
$error .= 'Error performing query "' . $templine . '": ' . $idPdo->error . '
';
}
}
catch (PDOException $e) {
echo "Erreur ! themeRestoreDB : " . $e->getMessage() . "
";
if(strstr($e,'Duplicate')) echo "Erreur ! existe déjà
";
$continuer=false;
}
if (isset($debug[2]) && $debug[2] == '1') { $debugMsg .= monDebug(2, ['templine=' => $templine], '');}
// Reset temp variable to empty
$templine = '';
$z++;
if (isset($debug[2]) && $debug[2] == '1') { $debugMsg .= monDebug(2, ['Lignes traités :' => $z], '');}
// echo '';
}
$x++;
}
}
if (isset($debug[2]) && $debug[2] == '1') { $debugMsg .= monDebug(2, ['Lignes traités :' => $z, ' sur' => $x, ' lignes' => ''], '');}
if (isset($debug[2]) && $debug[2] == '1') { $debugMsg .= monDebug(2, ['Thème' => $nomTableCibleCss, ' crée avec succès !' => ''], '');}
if (isset($debug[2]) && $debug[2] == '1') { $debugMsg .= monDebug(2, ['Thème' => $descTheme, ' crée avec succès !' => ''], '');}
?>