Exemple #1
0
                                        }
                                    }
                                    $time = time();
                                    if ($time % 3600 < $t) {
                                        $time -= 3600;
                                    }
                                    $time = (int) ($time / 3600) * 3600 + $t;
                                    $db->query("INSERT INTO log (time,addr{$vars}) VALUES ({$time},{$addr}{$val})\n");
                                    $rrd_file = $RRD_HOME . "/openhr20_" . $addr . ".rrd";
                                    if (file_exists($rrd_file)) {
                                        $cmnd = "rrdtool update " . $rrd_file . " " . $time . ":" . (int) $st['real'] . ":" . (int) $st['wanted'] . ":" . (int) $st['valve'] . ":" . (int) $st['window'];
                                        echo $cmnd . "\n";
                                        system($cmnd);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    if ($debug) {
        //debug log
        echo $line . "\n";
        $db->query("INSERT INTO debug_log (time,addr,data) VALUES (" . time() . ",{$addr},\"{$line}\")");
        $deleteThld = $db->lastInsertRowid() - $maxDebugLines;
        $db->query("DELETE FROM debug_log WHERE id<{$deleteThld}");
    }
    // echo "         duration ".(microtime(true)-$ts)."\n";
}
 public function insert($table, $data)
 {
     if (is_object($data)) {
         $data = (array) $data;
     }
     if (!is_string($table) || !is_array($data) || !$this->hasTable($table)) {
         throw new Exception("SQLITE: Invalid parameter.");
     }
     $data = $this->filterColumns($table, $data);
     $fields = array_keys($data);
     $condition = $this->buildInsertCondition($data)['condition'];
     $sql = "INSERT INTO '{$table}' ('" . implode("','", $fields) . "') VALUES (" . implode(",", $condition) . ")";
     $preparing = $this->queryPreparation(parent::prepare($sql), $this->buildInsertCondition($data)['values']);
     $preparing->execute();
     return parent::lastInsertRowid();
 }