Выдаёт ошибки, как решить?
Notice: Undefined property: Functions::$db in F:\home\test1.ru\www\engine\functions.php on line 6
Fatal error: Call to a member function escape() on a non-object in F:\home\test1.ru\www\engine\functions.php on line 6
functions.php line 6
echo $this->db->escape($login);
index.php
require_once("engine/DB.php");
$db = new DB("", "", "", "");
require_once("engine/functions.php");
$func = new Functions();
$func->auth("login", "pass");
db.php
class DB
{
private $link;
public function __construct($hostname, $username, $password, $database, $port = 3306)
{
$this->link = new mysqli($hostname, $username, $password, $database, $port);
if($this->link->connect_error)
{
exit("Ошибка: Не удалось соединиться с сервером базы данных!");
}
$this->link->query("SET NAMES 'utf8'");
$this->link->query("SET CHARACTER SET utf8");
$this->link->query("SET CHARACTER_SET_CONNECTION=utf8");
$this->link->query("SET SQL_MODE = ''");
}
public function query($sql)
{
if(!$resource = $this->link->query($sql))
{
exit("Error: " . $this->link->error . " (#" . $this->link->errno . ")" . "<br>" . $sql);
}
if(is_object($resource))
{
$i = 0;
$data = array();
while($row = $resource->fetch_assoc())
{
$data[$i] = $row;
$i++;
}
$resource->free();
$query = new stdClass();
$query->row = isset($data[0]) ? $data[0] : array();
$query->rows = $data;
$query->num_rows = $i;
unset($data);
return $query;
}
}
public function escape($value)
{
return $this->link->real_escape_string($value);
}
public function getLastId()
{
return $this->link->insert_id;
}
public function __destruct()
{
return $this->link->close();
}
}