Ejemplo n.º 1
0
<?php

$num = 100004313234244;
// notice this exceeds 32 bits
$conn = new sqlite3(':memory:');
$conn->query('CREATE TABLE users (id INTEGER NOT NULL, num INTEGER NOT NULL, PRIMARY KEY(id))');
$stmt = $conn->prepare('insert into users (id, num) values (:id, :num)');
$stmt->bindValue(':id', 1, SQLITE3_INTEGER);
$stmt->bindValue(':num', $num, SQLITE3_INTEGER);
$stmt->execute();
$stmt = $conn->query('SELECT num FROM users');
$result = $stmt->fetchArray();
var_dump($num, $result[0]);
Ejemplo n.º 2
0
$MyData = new pData();
/* DB filename Variable*/
$dbname = "/media/databases/temphumidata.db";
/* Get 24 hours ago timestamp */
$timestamp = strtotime('now') - 720 * 60 * 60;
/* Format timestamp for DB */
$monthago = date("Y-m-d H:i:s", $timestamp);
/* DB results */
$timestamp = $temperature = $humidity = "";
////////////////////////////////////////////////////////////////
// Get information from SQLITE3 Database
//
/* Get connection to statement */
$db = new sqlite3($dbname);
/* Prepared Statement creation */
$statement = $db->prepare('SELECT * FROM weather WHERE timestamp > :id;');
/* Bind Value to prepared statement */
$statement->bindValue(':id', $monthago);
/* Results array */
$results = $statement->execute();
/* While loop to extract results array for charting */
while ($row = $results->fetchArray()) {
    $timestamp[] = $row["timestamp"];
    $temperature[] = $row["temperature"];
    $humidity[] = $row["humidity"];
}
/* Close DB Connection */
$db->close();
////////////////////////////////////////////////////////////////
// Organise Data for Graphing
//
Ejemplo n.º 3
0
    $start = $time;
    return $start;
}
function StopTimer($startTime)
{
    $time = microtime();
    $time = explode(' ', $time);
    $time = $time[1] + $time[0];
    $finish = $time;
    return round($finish - $startTime, 4);
}
$database = new sqlite3('database/templogreg.db');
if (!$database) {
    $error = file_exists($yourfile) ? "Impossible to open, check permissions" : "Impossible to create, check permissions";
    die($error);
}
/*$structure = $database->query('PRAGMA table_info(temps);');
			while ($row = $structure->fetchArray()) {
			print_r($row);
			}
			*/
// 2015-09-01 22:20:09 because that's the last timestamp in the database
$statement = $database->prepare("SELECT ID, timestamp, temp FROM temps WHERE timestamp > datetime('2015-09-01 22:20:09', :time)");
$statement->bindValue(':time', '-' . $interval . ' hours');
//$now->ToString());
$starttime = StartTimer();
$result = $statement->execute();
$selecttime = StopTimer($starttime);
if (!$result) {
    die("Impossible to execute query.");
}