1) create a config.php
define('DBUSER','username');
define('DBPWD','password');
define('DBHOST','localhost');
define('DBNAME','database name');
2) db.php
dbHost, $this->user, $this->pass, $this->dbName);
if (mysqli_connect_error()) {
exit('Connect Error (' . mysqli_connect_errno() . ') '
. mysqli_connect_error());
}
parent::set_charset('utf-8');
}
public function dbquery($query)
{
if($this->query($query))
{
return true;
}
}
public function get_result($query)
{
$result = $this->query($query);
if ($result->num_rows > 0){
$row = $result->fetch_assoc();
return $row;
} else
return null;
}
}
?>
3) uses
require 'db.php';
$query="select * from tbl_session";
$sockets = db::getInstance()->get_result($query);
or any other query
$query="insert into `tbl_chats` (coloum_name) values('".$val."')";
$wisherID = db::getInstance()->dbquery($query);