Class DB
{
// Database connection
Var $ con = FALSE;
Function DB ($ MYSQL_HOST = MYSQL_HOST, $ MYSQL_USER = MYSQL_USER, $ MYSQL_PASS = MYSQL_PASS, $ MYSQL_DB = MYSQL_DB)
{
$ This-> con = @ mysql_connect ($ MYSQL_HOST, $ MYSQL_USER, $ MYSQL_PASS) or die ("cocould not connect to database ");
If ($ this-> con)
{
@ Mysql_select_db ($ MYSQL_DB, $ this-> con) or die ("cocould not select database ");
}
Return $ this-> con;
}
Function Query ($ SQL, $ tran = false)
{
// If (! File_exists (MYSQL_LOG ))
//{
// @ Umask (0 );
// @ Mkdir (MYSQL_LOG, 0777 );
//}
// & Frac14; response ;־
// $ Fp = @ fopen (MYSQL_LOG.date ("Ymd"). ". txt", "");
// Zookeeper ־
// @ Fwrite ($ fp, date ("Y-m-d H: I: s"). "| $ SQL ");
// @ Fclose ($ fp );
$ This-> SQL = $ SQL;
If ($ tran)
{
$ This-> result = @ mysql_query ($ this-> SQL) OR $ this-> RollBack ();
Return $ this-> result;
}
Else
{
Mysql_query ("set names 'utf8 '");
// Mysql_query ("set names 'gbk '");
$ This-> result = @ mysql_query ($ this-> SQL );
Return $ this-> result;
}
}
Function RollBack ()
{
$ This-> Query ("ROLLBACK ;");
Die ("MySQL ROLLBACK ;");
}
Function NumRows ($ result)
{
$ This-> result = $ result;
Return @ mysql_num_rows ($ this-> result );
}
Function FetchRow ($ result)
{
$ This-> result = $ result;
Return @ mysql_fetch_row ($ this-> result );
}
Function FetchArray ($ result)
{
$ This-> result = $ result;
Return @ mysql_fetch_array ($ this-> result, MYSQL_ASSOC );
}
Function FetchArray2 ($ result)
{
$ This-> result = $ result;
Return @ mysql_fetch_array ($ this-> result, MYSQL_BOTH );
}
Function FetchObject ($ result)
{
$ This-> result = $ result;
Return @ mysql_fetch_object ($ this-> result );
}
Function FreeResult ($ result)
{
$ This-> result = $ result;
Return @ mysql_free_result ($ this-> result );
}
Function DataSeek ($ result)
{
// Reset the record set pointer
$ This-> result = $ result;
Return mysql_data_seek ($ this-> result, 0 );
}
Function InsertID ()
{
// $ This-> con = $ con;
Return @ mysql_insert_id ($ this-> con );
}
Function Close ()
{
If ($ this-> con)
{
@ Mysql_close ($ this-> con );
}
}
}