任何人都可以帮助我转换此文件,但有很多错误 不建议使用:mysql_query():不建议使用mysql扩展,以后将删除:使用mysqli或PDO代替
$num_queries = 0;
$total_time = 0;
class ADO
{
function ADO($host,$user,$password,$database)
{
$this->connection=mysqli_connect($host,$user,$password);
if(!$this->connection)
{
echo "<br>Database Error!!!<br>".mysqli_error();
}
mysqli_select_db($database);
}
function exec($sql)
{
// echo "<br />".$sql;
//exit;
// global $num_queries;
// global $total_time;
// $num_queries++;
// $start_time = microtime(true);
// echo "<br />".$num_queries." ".$sql;
$result=mysqli_query($sql,$this->connection) ;
if(!$result)
echo "<p>ERROR::".mysqli_error()."<br><strong>".$sql."</strong></p>";
// $time_taken = round(microtime(true) - $start_time, 4 );
// $total_time += $time_taken ;
// if($time_taken >= 0.01)
// echo "<br /> Time taken is ".$time_taken.' total time is '.$total_time;
// echo $sql;
// exit;
if($result)
{
return $result;
}
else
{
//echo "<br>Error in Query!!! $sql<br>".mysql_error();
return false;
//exit();
}
}
function error()
{
return mysql_error();
}
function affected_rows()
{
return mysql_affected_rows();
}
function fetch($result)
{
$res = mysql_fetch_array($result);
// echo mysql_error();
return $res;
}
function fetch_assoc($result)
{
return mysql_fetch_assoc($result);
}
function free($result)
{
return mysql_free_result($result);
}
function count($result)
{
return mysql_num_rows($result);
}
function count_res($result)
{
return @mysql_num_rows($result);
}
function id()
{
return mysql_insert_id();
}
function end()
{
mysql_close($this->connection);
}
}
global $ado;
$ado = new ADO($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME) or die("database connection error");
如果有人可以帮助我,请将其从mysql转换为mysqli,我非常感谢。 霍尔脚本目前正在使用mysql进行编程,无法正常运行