<th>Pax</th> <th>Tail</th> <th>Pilot</th> <th>Client</th> <th>Leave</th> <th>Return</th> <th>Fuel</th> <th>Notes</th> </tr> </thead> <tbody> <?php $date = date("m/d/Y"); //read data from database $query = "SELECT status, date, route, pax, tail, pilot, client, leaves, returns, fuel, notes FROM {$mytable} WHERE date >= '{$date}' ORDER BY date ASC, leaves ASC"; $results = $base->arrayQuery($query, SQLITE_ASSOC); $size = count($results); for ($i = 0; i < $size; $i++) { $arr = $results[$i]; if (count($arr) == 0) { break; } $status = $arr['status']; $date = $arr['date']; $route = $arr['route']; $pax = $arr['pax']; $tail = $arr['tail']; $pilot = $arr['pilot']; $client = $arr['client']; $leaves = $arr['leaves']; $returns = $arr['returns'];
echo 'Number of rows modified: ', sqlite_changes($dbhandle); } $dbhandle = new SQLiteDatabase('mysqlitedb'); $query = $dbhandle->query("UPDATE users SET email='*****@*****.**' WHERE username='******'"); if (!$query) { exit('Error in query.'); } else { echo 'Number of rows modified: ', $dbhandle->changes(); } $dbhandle = sqlite_open('sqlitedb'); $result = sqlite_array_query($dbhandle, 'SELECT name, email FROM users LIMIT 25', SQLITE_ASSOC); foreach ($result as $entry) { echo 'Name: ' . $entry['name'] . ' E-mail: ' . $entry['email']; } $dbhandle = new SQLiteDatabase('sqlitedb'); $result = $dbhandle->arrayQuery('SELECT name, email FROM users LIMIT 25', SQLITE_ASSOC); foreach ($result as $entry) { echo 'Name: ' . $entry['name'] . ' E-mail: ' . $entry['email']; } $data = array('one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten'); $dbhandle = sqlite_open(':memory:'); sqlite_query($dbhandle, "CREATE TABLE strings(a)"); foreach ($data as $str) { $str = sqlite_escape_string($str); sqlite_query($dbhandle, "INSERT INTO strings VALUES ('{$str}')"); } function max_len_step(&$context, $string) { if (strlen($string) > $context) { $context = strlen($string); }
<?php $fname = 'direcciones.sqlite'; @unlink($fname); $db = new SQLiteDatabase($fname); $sql = "CREATE TABLE emails (\n id INTEGER PRIMARY KEY,\n nombre STRING NOT NULL,\n correo STRING NOT NULL\n )"; $db->queryExec($sql); $db->queryExec("INSERT INTO emails (nombre, correo) " . "VALUES ('Atila T. Hun', '*****@*****.**')"); $db->queryExec("INSERT INTO emails (nombre, correo) " . "VALUES ('Hermes Trismegisto', '*****@*****.**')"); $db->queryExec("INSERT INTO emails (nombre, correo) " . "VALUES ('A. Rosenkratz', '*****@*****.**')"); $rows = $db->arrayQuery("SELECT DISTINCT nombre,correo FROM emails"); foreach ($rows as $row) { echo "- {$row['nombre']}, {$row['correo']}\n"; } ?>
<?php // DEBUG: put the visualizer path as parameter somewhere? $what = isset($_GET['what']) ? $_GET['what'] : 'html_index'; $id = isset($_GET['id']) ? $_GET['id'] : 'html_index'; // Create SQLiteDatabase object if (!($db = new SQLiteDatabase('db.sqlite', 0666))) { die("Cant connect to the file database. Make sure the db file is in the right place and the directory is writable by the web server."); } switch ($what) { // Ask for all breeds and just shows them as text case 'html_index': $q = 'SELECT id,breed_name,picture,description FROM dogs ORDER BY breed_name'; @($result = $db->arrayQuery($q)); if ($result === false) { die("Cant execute {$q}. Make sure the db file is in the right place and the directory is writable by the web server."); } else { foreach ($result as $dog) { echo 'Id ' . $dog['id'] . 'Breed: ' . $dog['breed_name'] . ', picture: ' . $entry['picture']; } } break; // Ask for all breeds in an index format // Ask for all breeds in an index format case 'breeds': $q = 'SELECT id,breed_name,description,picture FROM dogs ORDER BY breed_name'; @($result = $db->arrayQuery($q)); if ($result === false) { die("Cant execute {$q}. Make sure the db file is in the right place and the directory is writable by the web server."); } else { echo '<div class="widget widget_draggable">' . ' <div class="widgetHeader toBeResized">' . ' <div class="leftIcons"><ul>' . ' <li class="collapse"><a class="expanded" href="#" title="Collapse">Collapse</a></li>' . ' </ul></div>' . ' <div class="title"><h4 class="widgetHeaderTitle">Breeds A-Z</h4></div>' . ' <div class="rightIcons"><ul>' . ' <li class="drag"><a href="#" title="Drag">Drag</a></li>' . ' </ul></div>' . ' </div>' . ' <div class="widgetContent expanded"><div>';
/** * Gets object from database * @param integer $feedbackId * @return object $Feedback */ function Get($flightId) { try { /* $Database = new PDO($GLOBALS['configuration']['pdoDriver'].':'.$GLOBALS['configuration']['sqliteDatabase']); $stmt = $Database->prepare("select * from schedule where id= ? LIMIT 1"); if ($stmt->execute(array($flightId))) { while ($row = $stmt->fetch()) { $this->flightId = $row['id']; $this->fstatus = $row['status']; $this->fdate = $row['date']; $this->route = $row['route']; $this->pax = $row['pax']; $this->tail = $row['tail']; $this->pilot = $row['pilot']; $this->client = $row['client']; $this->leaves = $row['leaves']; $this->returns = $row['returns']; $this->fuel = $row['fuel']; $this->notes = $row['notes']; } } return $this; */ //$dbname='../data/flights.sqlite'; //$mytable = 'schedule'; $dbname = DB_NAME; $mytable = DB_TABLE; $base = new SQLiteDatabase($dbname, 0666, $err); if ($err) { exit($err); } //read data from database $query = "select * from schedule where id= %d LIMIT 1"; $query = sprintf($query, $flightId); $results = $base->arrayQuery($query, SQLITE_ASSOC); $size = count($results); foreach ($results as $row) { $this->flightId = $row['id']; $this->fstatus = $row['status']; $this->fdate = $row['date']; $this->route = $row['route']; $this->pax = $row['pax']; $this->tail = $row['tail']; $this->pilot = $row['pilot']; $this->client = $row['client']; $this->leaves = $row['leaves']; $this->returns = $row['returns']; $this->fuel = $row['fuel']; $this->notes = $row['notes']; } return $this; } catch (Exception $e) { print "Error!: " . $e->getMessage() . "<br/>"; die; } }
<?php $db = new SQLiteDatabase(dirname(__FILE__) . "/ip.db"); $r = $db->arrayQuery("SELECT * FROM sqlite_master LIMIT 1", SQLITE_ASSOC); echo '<pre>' . print_r($r, true) . '</pre>';