class mysql_db
{
var $host="127.0.0.1";
var $user="root";
var $passwd="";
function connect()
{
$con=mysql_connect($this-host,$this-user,$this-passwd);
if(!$con)
{
echo "mysql is not connect!".mysql_error()."
";
exit();
}
$select=mysql_select_db("soohuo");
if(!$select)
{
echo "select datebase error";
}
return $con;
}
function query($con,$sql)
{
if(empty($con))
{
echo "mysql connect success value is not null!
";
exit();
}
if(empty($sql))
{
echo "mysql sql value is not null!
";
exit();
}
$result=mysql_query($sql,$con);
/*
if(!$result)
{
echo "mysql sql error!
";
exit();
}
*/
return $result;
}
function fetch_row($result)
{
if(empty($result))
{
echo "mysql query success is null!
";
exit();
}
$row=mysql_fetch_row($result);
return $row;
}
function close($con)
{
if(empty($con))
{
echo "odbc connect is not null!
";
exit();
}
mysql_close($con);
}
}
?
不做解释了,很好理解的
使用中的真实情况是同时连接2个库,我一个是mysql一个是oracle,我用这2个类完成的