- some debugging
- adding logs in mysql database
This commit is contained in:
33
class/db.php
Normal file
33
class/db.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
class db extends mysqli
|
||||
{
|
||||
public $mysqlServer = "127.0.0.1";
|
||||
public $username = "moha";
|
||||
public $passwd = "MysqlMoha";
|
||||
public $database = "moha";
|
||||
|
||||
function __construct($mysqlServer, $username, $passwd, $database)
|
||||
{
|
||||
return $this->connect($mysqlServer, $username, $passwd, $database);
|
||||
}
|
||||
|
||||
function protect($string)
|
||||
{
|
||||
return $this->real_escape_string($string);
|
||||
}
|
||||
|
||||
function logProperty($device, $property, $value)
|
||||
{
|
||||
$query = "SELECT * FROM logs WHERE device='" . $device->ieeeAddress . "' AND property='" .
|
||||
$query = "IF (EXISTS INSERT INTO logs(device, property, value) VALUES(" . $device->ieeeAddress . ", " . $property . ", " . $value . ") ON DUPLICATE KEY UPDATE value=" . $value
|
||||
}
|
||||
}
|
||||
|
||||
$mohaDB = new db($mysqlServer, $username, $passwd, $database);
|
||||
if ($mohaDB->connect_error)
|
||||
{
|
||||
logger(ERROR, _("Mysql connection failed: ") . $db->connect_error);
|
||||
}
|
||||
|
||||
?>
|
Reference in New Issue
Block a user