▒█▀▀█ █▀▀ █░░█ ▒█▀▀█ █░░█ ░▀░ █▀▀█
▒█▄▄█ ▀▀█ █▄▄█ ▒█░░░ █▀▀█ ▀█▀ █░░█
▒█░░░ ▀▀▀ ▄▄▄█ ▒█▄▄█ ▀░░▀ ▀▀▀ █▀▀▀
PostreSQL version of PsyDB+ 1) { $connstr = ""; foreach (array_keys($details) as $str) { if ($details[$str] != "") { $connstr.=$str . "=" . $details[$str] . ' '; } } $this->c = pg_connect($connstr) or die('Could not connect database'); $this->opened = true; } } function __destruct() { if ($this->opened) { pg_close($this->c); } } public function rquery($query) { if ($this->opened) { $this->res = pg_query($this->c, $query) or die('Cannot run query: ' . $query); return $this->res; } else { $this->res = pg_query($query) or die('Cannot run query: ' . $query); return $this->res; } } public function aquery($query) { $res = $this->rquery($query); $data = pg_fetch_array($res); $cikti = array(); foreach ($data as $key => $value) { if (!is_int($key)) { $cikti[$key] = $value; } } return $cikti; } private function multiparse($res) { $cikti = array(); while ($this->buf = pg_fetch_assoc($res)) { array_push($cikti, $this->buf); } return $cikti; } public function mquery($query) { $link = $this->rquery($query); return $this->multiparse($link); } public function insert($tablo, $array) { /* "column" => "value" formatli bir array'i tabloya basar * array icinde en az 2 baslik bulunmali! */ $toplam = count($array); $basliklar = array_keys($array); $bstr = ""; $vstr = ""; for ($i = 0; $i < $toplam - 1; $i++) { $bstr.=pg_escape_string($basliklar[$i]) . ', '; if (is_numeric($array[$basliklar[$i]])) { $vstr.= $array[$basliklar[$i]] . ", "; } else { $vstr.= "'" . pg_escape_string($array[$basliklar[$i]]) . "', "; } } $bstr.=pg_escape_string($basliklar[$toplam - 1]); $fchar = $array[$basliklar[$i]]; if (is_numeric($fchar{1})) { $vstr.= $array[$basliklar[$i]]; } else { $vstr.= "'" . pg_escape_string($array[$basliklar[$i]]) . "'"; } $cikti = $this->rquery("INSERT INTO " . $tablo . " (" . $bstr . ") VALUES (" . $vstr . ");"); return $cikti; } public function newtable($tablo, $array) { /* "fieldname" => "coltype" formatli bir array'den tablo olusturur * array icinde en az 2 baslik bulunmali! */ $toplam = count($array); $basliklar = array_keys($array); $bstr = ""; for ($i = 0; $i < $toplam - 1; $i++) { $bstr.=$basliklar[$i] . ' ' . $array[$basliklar[$i]] . ', '; } $bstr.=$basliklar[$i] . ' ' . $array[$basliklar[$i]]; $cikti = $this->rquery("CREATE TABLE " . $tablo . " (" . $bstr . ") WITH (OIDS = FALSE);"); return $cikti; } public function update($tablo, $array, $where, $value) { /* "column" => "value" formatli bir array'i tabloya basar * array icinde en az 2 baslik bulunmali! * * to psy: Postresql doesnt accept repeated 'SET' statement * */ $toplam = count($array); $basliklar = array_keys($array); $bstr = "SET"; for ($i = 0; $i < $toplam - 1; $i++) { if (is_numeric($array[$basliklar[$i]])) { $bstr.=' ' . $basliklar[$i] . '=' . $array[$basliklar[$i]] . ', '; } else { $bstr.=' ' . $basliklar[$i] . '=' . "'" . pg_escape_string($array[$basliklar[$i]]) . "'" . ', '; } } $bstr.=' ' . $basliklar[$i] . '=' . "'" . pg_escape_string($array[$basliklar[$i]]) . "'"; $cikti = $this->rquery("UPDATE " . $tablo . " " . $bstr . ' WHERE ' . $where . '=' . "'" . $value . "';"); return $cikti; } public function q2table($query, $id = "") { $array = $this->mquery($query); if ($id == "") { $id = md5($query); } if (count($array) > 1) { $output = ''; foreach (array_keys($array[0]) as $title) { $output .= '' . $title . ''; } $output .= ''; foreach ($array as $inarray) { $output.=''; foreach (array_keys($inarray) as $title) { $output .= '' . $inarray[$title] . ''; } $output.=''; } $output.=''; return $output; } else { return "No Results"; } } } ?>
libraspi.js
2 Year, 11 Month ago
wifi_sensor_station.ino
serialrelay.ino
sensorstation.ino
class.dbipc.php