Update of /cvsroot/phpmp/phpMP/core/dba
In directory sc8-pr-cvs1:/tmp/cvs-serv16640
Added Files:
mysql.php
Log Message:
--- NEW FILE: mysql.php ---
<?php
class sql_db
{
var $db_connection_id;
var $db_query_result = 0;
var $db_query_count = 0;
var $row = array();
var $rowset = array();
//
// CONSTRUCTOR - sql_connect
//
function sql_db($hostname, $username, $password, $database, $persistant)
{
$this->hostname = $hostname;
$this->username = $username;
$this->password = $password;
$this->database = $database;
$this->persistant = $persistant;
if($this->persistant == TRUE)
{
$this->db_connection_id = @mysql_pconnect($this->hostname, $this->username, $this->password);
}
else
{
$this->db_connection_id = @mysql_connect($this->hostname, $this->username, $this->password);
}
if(! $this->db_connection_id)
{
if(ERROR_REPORTING == FALSE)
{
return false;
}
else
{
// something like that :D
die(mysql_error());
}
}
else
{
if(! empty($this->database))
{
$dbselect = @mysql_select_db($this->database);
if(! $dbselect)
{
@mysql_close($this->db_connection_id);
$this->db_connection_id = $dbselect;
}
}
return $this->db_connection_id;
}
}
//
// DESTRUCTOR - sql_close
// - based on sql_close from phpBB 2.0.6
//
function sql_close($db_connect_id = 0)
{
if($db_connect_id == 0)
{
$db_connect_id = $this->db_connection_id;
}
if($db_connect_id != FALSE)
{
if($this->db_query_result)
{
@mysql_free_result($this->db_query_result);
}
$result = @mysql_close($db_connect_id);
return $result;
}
else
{
return false;
}
}
//
// OTHER BASE METHODS
//
//
// sql_query
//
function sql_query($query = '', $return_off = TRUE)
{
unset($this->db_query_result); // remove previous query result
if(! empty($query))
{
$this->db_query_count++;
$this->db_query_result = @mysql_query($query, $this->db_connection_id);
}
if( $this->db_query_result)
{
return $this->db_query_result;
}
else
{
if($return_off == TRUE)
{
die(mysql_error());
}
else
{
return false;
}
}
}
} // End of sql_db
?>
|