The 'public' from classes should be removed completely from functions and replace with var in strings.
So,
/**
* Extends MyBB's MySQLi class with an new query command and some more.
*/
class mysqli_db extends databaseEngine
{
/**
* Last query that was made with query().
* Great since I don't like cludder in code.
*/
public $last_query;
/**
* Last query that was made with query().
* Great since I don't like cludder in code.
*/
public $prefix = "";
/**
* Start and end, for limit query.
*/
public $limit, $start = 0;
/**
* $usergroups will contain all usergroups with new and old id.
* $users will contain all users after selecting them.
*/
public $usergroups, $users = array();
/**
* Starts the database.
*
* @param string The hostname.
* @param string The username.
* @param string The password.
* @param string The database.
* @param string The prefix.
*/
public function start($host, $user, $pass, $database, $prefix="")
{
$host = (strpos($host, ':')) ? explode(':', $host, 2) : array($host, NULL);
$this->link = new mysqli($host[0], $user, $pass, $database, $host[1]);
$this->prefix = $prefix;
if(mysqli_connect_errno()) {
$this->error();
}
}
/**
* Runs a mysql query.
*
* @param string The query.
* @return mysql resource.
*/
public function query($string, $unbuffered = false)
{
$string = str_replace('#_', $this->prefix, $string);
if($this->limit > 0 && preg_match("#^\s*select#i", $string) && !preg_match("#^\s*limit#i", $string))
{
$string .= " LIMIT ".$this->start.", ".$this->limit;
}
$query = $this->link->query($string, ($unbuffered ? MYSQLI_USE_RESULT : MYSQLI_STORE_RESULT));
if($this->errno())
{
$this->dberror($string);
}
$this->last_query = $query;
$this->query_count++;
$this->querylist[] = $string;
return $query;
}
}
replace with
/**
* Extends MyBB's MySQLi class with an new query command and some more.
*/
class mysqli_db extends databaseEngine
{
/**
* Last query that was made with query().
* Great since I don't like cludder in code.
*/
var $last_query;
/**
* Last query that was made with query().
* Great since I don't like cludder in code.
*/
var $prefix = "";
/**
* Start and end, for limit query.
*/
var $limit, $start = 0;
/**
* $usergroups will contain all usergroups with new and old id.
* $users will contain all users after selecting them.
*/
var $usergroups, $users = array();
/**
* Starts the database.
*
* @param string The hostname.
* @param string The username.
* @param string The password.
* @param string The database.
* @param string The prefix.
*/
function start($host, $user, $pass, $database, $prefix="")
{
$host = (strpos($host, ':')) ? explode(':', $host, 2) : array($host, NULL);
$this->link = new mysqli($host[0], $user, $pass, $database, $host[1]);
$this->prefix = $prefix;
if(mysqli_connect_errno()) {
$this->error();
}
}
/**
* Runs a mysql query.
*
* @param string The query.
* @return mysql resource.
*/
function query($string, $unbuffered = false)
{
$string = str_replace('#_', $this->prefix, $string);
if($this->limit > 0 && preg_match("#^\s*select#i", $string) && !preg_match("#^\s*limit#i", $string))
{
$string .= " LIMIT ".$this->start.", ".$this->limit;
}
$query = $this->link->query($string, ($unbuffered ? MYSQLI_USE_RESULT : MYSQLI_STORE_RESULT));
if($this->errno())
{
$this->dberror($string);
}
$this->last_query = $query;
$this->query_count++;
$this->querylist[] = $string;
return $query;
}
}