I want to access the domoticz database for consultation with a php page and I have some problems ...
Domoticz turns on a raspberry. I have on this same raspberry lighttp, php and sqlite3. My script is
Code: Select all
<?php
class MyDB extends SQLite3 {
function __construct() {
$chemin="/home/pi/domoticz/";
$dbname='domoticz.db';
$this->open($chemin.$dbname);
}
}
$db = new MyDB();
if(!$db) {
echo $db->lastErrorMsg();
} else {
echo "Opened database successfully<br/>";
echo $db->lastErrorMsg(),"<br/>";
}
// Lecture des dernières températures et températures min et max pour toutes les sondes
$sql = 'SELECT ID, Name, sValue, LastUpdate FROM DeviceStatus WHERE Type = 80 ORDER BY ID ASC';
$results = $db->query($sql) ;
echo $db->lastErrorMsg(),"<br/>";
var_dump($results);
while ($row = $results->fetchArray(SQLITE3_NUM)) {
.... suite du code ..
}
Thanks for help.