Source code raw phps
<?php
require_once 'libraries/class.DB_Common.php';
require_once 'libraries/class.DB_mySQL_Results.php';
class DB_mySQL extends DB_Common
{
protected $_link;
protected $_resources = array(null);
public function __cosntruct() {
}
public function connect($host, $username, $password, $database)
{
$this->_link = mysql_connect($host, $username, $password);
if (!$this->_link) {
$this->notify('Can\'t connect', Bot::U_ERROR | Bot::U_DB);
} else {
$this->notify('Connected to the server!', Bot::U_DEBUG | Bot::U_DB);
}
$selected = mysql_select_db($database, $this->_link);
if (!$selected) {
$this->notify('Unable to select a database', Bot::U_ERROR | Bot::U_DB);
} else {
$this->notify('Selected the database '.$database, Bot::U_DEBUG | Bot::U_DB);
}
}
public function execute($query)
{
$resource = mysql_query($query, $this->_link);
if (!$resource) {
$this->notify('SQL query failed : '.mysql_error($this->_link) .' The query was: '.$query, Bot::U_ERROR | Bot::U_DB);
} else {
$this->notify('SQL query executed: "'.$query.'"', Bot::U_DEBUG | Bot::U_DB);
}
if (is_resource($resource)) {
return new DB_mySQL_Results($resource);
} else {
return $resource;
}
}
public function insertedId()
{
return mysql_insert_id();
}
public function escape($value)
{
return mysql_real_escape_string($value);
}
}
?>
Comments
There is currently no comment here.