final public function setMySQL($key, $value)
{
$this->mysql[$key] = $value;
}
/*-------------------------------Manage Connection-------------------------------------*/
final public function connect($type)
{
global $core, $_CONFIG;
if(!$this->connected)
{k
$this->connection = $this->mysql[$type]($_CONFIG['mysql']['127.0.0.1'], $_CONFIG['mysql']['test1'], $_CONFIG['mysql']['12345']);
if($this->connection)
{
$mydatabase = $this->mysql['nexus']($_CONFIG['mysql']['nexus'], $this->connection);
if($mydatabase)
{
$this->connected = true;
}
else
{
$core->systemError('MySQL Engine', 'MySQL could not connect to database');
}
}
else
{
$core->systemError('MySQL Engine', 'MySQL could not connect to host');
}
}
}
final public function disconnect()
{
global $core;
if($this->connected)
{
if($this->mysql['close'])
{
$this->connected = false;
}
else
{
$core->systemError('MySQL Engine', 'MySQL could not disconnect.');
}
}
}
/*-------------------------------Secure MySQL variables-------------------------------------*/
final public function secure($var)
{
return $this->mysql['escape_string'](stripslashes(htmlspecialchars($var)));
}
/*-------------------------------Manage MySQL queries-------------------------------------*/
final public function query($sql)
{
return $this->mysql['query']($sql, $this->connection) or die(mysql_error());
}
final public function num_rows($sql)
{
return $this->mysql['num_rows']($this->mysql['query']($sql, $this->connection));
}
final public function result($sql)
{
return $this->mysql['result']($this->mysql['query']($sql, $this->connection), 0);
}
final public function free_result($sql)
{
return $this->mysql['free_result']($sql);
}
final public function fetch_array($sql)
{
$query = $this->mysql['query']($sql, $this->connection);
$data = array();
while($row = $this->mysql['fetch_array']($query))
{
$data[] = $row;
}
return $data;
}
final public function fetch_assoc($sql)
{
return $this->mysql['fetch_assoc']($this->mysql['query']($sql, $this->connection));
}
}
?>
Bas_1 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.