1
0
moha/class/db.php

34 lines
878 B
PHP
Raw Normal View History

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