mirror of
https://github.com/agdsn/ancient-weatherstation.git
synced 2026-06-19 23:07:59 +00:00
Finished temperature module in Webfrontend
git-svn-id: file:///home/jan/tmp/wetterstation/trunk@25 dd492736-c11a-0410-ad51-8c26713eaf7f
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<?
|
||||
class Connection{
|
||||
|
||||
var $conn = NULL;
|
||||
|
||||
function Connection(){
|
||||
$this->conn = NULL;
|
||||
}
|
||||
|
||||
function _createConn(){
|
||||
if($this->conn == NULL){
|
||||
$this->conn = pg_connect("host=141.30.228.39 dbname=wetter user=losinshi")
|
||||
or die('Verbindungsaufbau fehlgeschlagen: ' . pg_last_error());
|
||||
}
|
||||
}
|
||||
|
||||
function closeConn(){
|
||||
if($this->conn != NULL){
|
||||
pg_close($this->conn);
|
||||
$this->conn = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
function fetchQueryResultLine($query){
|
||||
$this->_createConn();
|
||||
$result = pg_query($this->conn, $query)
|
||||
or die('Abfrage fehlgeschlagen: ' . pg_last_error());
|
||||
$array = pg_fetch_assoc($result);
|
||||
//print_r($array);
|
||||
return $array;
|
||||
}
|
||||
|
||||
function fetchQueryResultSet($query){
|
||||
$returnArray = array();
|
||||
$this->_createConn();
|
||||
$result = pg_query($this->conn, $query)
|
||||
or die('Abfrage fehlgeschlagen: ' . pg_last_error());
|
||||
while($array = pg_fetch_assoc($result))
|
||||
array_push($returnArray, $array);
|
||||
return $returnArray;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user