1
0
moha/class/db.php
daniel Tartavel cd20e973cd - some debugging
- adding logs in mysql database
2022-01-10 00:12:30 +01:00

34 lines
878 B
PHP

<?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);
}
?>