1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
<?php
include("wp-config.php");
$prefix="wp_";
echo "\n<pre>\n";
echo DB_HOST;
function bdd_connect()
{
global $sql_config;
$link=@mysql_connect(DB_HOST,DB_USER,DB_PASSWORD);
if ($link && @mysql_select_db(DB_NAME))
return ($link);
return (FALSE);
}
$time=array();
$time[]=time(); // timer
$file=@file("tmp/sql.sql");
if (!$file) die("Update not possible. Nothing is changed");
$nbr_ligne=count($file);
$link=bdd_connect();
if (!$link) die("SQL connexion failed");
$tables=array($prefix."posts");
foreach($tables as $t) $req=mysql_query("DELETE FROM $t");
$time[]=time(); // timer
$query=0;
for($i=0;$i<$nbr_ligne;$i++) {
$ligne=$file[$i];
if ($ligne{0} != "#" && $ligne!='') {
$req=@mysql_query(str_replace("\n","",$ligne));
$query++;
}
}
$time[]=time(); // timer
$diff=array($time[1]-$time[0],$time[2]-$time[1],$time[2]-$time[0]);
echo "Module's download : ".$diff[0]." seconds\n";
echo $query. " querys : ".$diff[1]." seconds\n";
echo "Total : ".$diff[2]." seconds\n";
echo "</pre>\n";
@mysql_close($link);
?> |