Esempio n. 1
0
<?php

require_once 'workflows.php';
require_once 'sqlitedb.php';
$input = $argv[1];
$w = new Workflows();
$db = new SQLiteDB('autocomplete.db');
$table = array('handle' => 'text PRIMARY KEY');
$db->create_table($table, 'users');
$remaining = 140 - count(str_split(trim($input)));
$w->result('tweet', $input, 'Tweet: ' . $input, 'Remaining: ' . $remaining . '. Press Cmd+Enter to send.', 'icon.png');
$words = explode(' ', $input);
if (preg_match('^@[a-zA-Z0-9-_]{2,}^', end($words))) {
    $search = substr(end($words), 1);
    $matches = $db->select('*')->from('users')->like('handle', $search)->get();
    array_pop($words);
    $words = implode(' ', $words);
    foreach ($matches as $match) {
        $w->result('autoc', $words . ' @' . $match->handle . ' ', $match->handle, '', 'icon.png', 'no', $words . ' @' . $match->handle . ' ');
    }
}
echo $w->toxml();
Esempio n. 2
0
File: sync.php Progetto: stas/epfh
function orph_clean_db($db_file)
{
    $db = new SQLiteDB($db_file);
    $db->query("\n\t\t\tDROP TABLE products;\n\t\t");
    return "Tables destroyed!";
}
Esempio n. 3
0
		}
		
		foreach ($ref->getConstants() as $name => $value)
		{
			$db->insert('constants', array('name' => $name, 'class' => $id));
		}
	}

	$dbname = 'phpsymbols.db';

	if (file_exists($dbname))
	{
		unlink($dbname);
	}

	$db = new SQLiteDB($dbname);

	$db->query("CREATE TABLE `classes` (`id` INTEGER PRIMARY KEY, `name` STRING, `doc` STRING, `parent` INTEGER, `interface` INTEGER)");
	$db->query("CREATE INDEX `class_name` ON `classes` (`name`)");
	$db->query("CREATE INDEX `class_parent` ON `classes` (`parent`)");
	
	$db->query("CREATE TABLE `interfaces` (`class` INTEGER, `interface` INTEGER)");
	$db->query("CREATE INDEX `interface_class` ON `interfaces` (`class`)");
	$db->query("CREATE INDEX `interface_interface` ON `interfaces` (`interface`)");
	
	$db->query("CREATE TABLE `properties` (`id` INTEGER PRIMARY KEY, `name` STRING, `doc` STRING, `class` INTEGER, `flags` INTEGER)");
	$db->query("CREATE INDEX `property_name` ON `properties` (`name`)");
	$db->query("CREATE INDEX `property_class` ON `properties` (`class`)");
	$db->query("CREATE INDEX `property_flags` ON `properties` (`flags`)");
	
	$db->query("CREATE TABLE `constants` (`id` INTEGER PRIMARY KEY, `name` STRING, `class` INTEGER)");
 public static function testDB()
 {
     static $db_file = 'test/SQLiteTest.db';
     static $db_sql = 'SQLiteDB.sql';
     static $sqlite3_prog = 'sqlite3';
     static $ini_file = 'test/db_def_cfg.ini';
     static $ini_contents = "\\\n[SQLiteDB]\nfilename=test/SQLiteTest.db\n";
     // create test SQLite database
     unlink($db_file);
     exec("{$sqlite3_prog} -init {$db_sql} {$db_file}");
     // SQLiteDB::connect test
     $db = SQLiteDB::connect(array('filename' => $db_file));
     if (!$db instanceof SQLiteDB) {
         throw new Exception('SQLiteDB::connect test failed');
     }
     // SQLiteDB::connectFromIni test
     file_put_contents($ini_file, $ini_contents);
     $db = SQLiteDB::connectFromIni('test/db_def_cfg.ini');
     if (!$db instanceof SQLiteDB) {
         throw new Exception('SQLiteDB::connect test failed');
     }
     return $db;
 }
Esempio n. 5
0
File: index.php Progetto: stas/epfh
<?php

include "config.php";
$db = new SQLiteDB($db_file);
$results = $db->query("\n\t\tSELECT * FROM products\n\t\t");
$products = "";
while (sqlite_has_more($results)) {
    $result = $db->fetch_array($results, DB_ASSOC);
    $products .= "<li id=\"prd_" . $result['EID'] . "\">" . "\n";
    $products .= "\t" . "<div class=\"full_price\">" . "\n";
    $products .= "\t\t" . "<span class=\"code\">" . $result['code'] . "</span> &mdash;" . "\n";
    $products .= "\t\t" . "<span class=\"price\">" . $result['price'] . "</span>" . "\n";
    $products .= "\t\t" . "<span class=\"curr\">" . $result['currency'] . "</span>" . "\n";
    $products .= "\t\t" . "<form method=\"get\" action=\"" . $buy_url . "\">" . "\n";
    $products .= "\t\t\t" . "<input type=\"hidden\" name=\"PRODS\" value=\"" . $result['EID'] . "\" />" . "\n";
    $products .= "\t\t\t" . "<input type=\"hidden\" name=\"QTY\" value=\"1\" />" . "\n";
    $products .= "\t\t\t" . "<input type=\"submit\" class=\"button\" value=\"Buy now!\" />" . "\n";
    $products .= "\t\t" . "</form>" . "\n";
    $products .= "\t" . "</div>" . "\n";
    $products .= "\t" . "<h3 class=\"name\">" . $result['name'] . "</h3>" . "\n";
    $products .= "\t" . "<p class=\"desc_short\">" . htmlspecialchars($result['desc_short']) . "... </p>" . "\n";
    $products .= "\t" . "<p class=\"desc_long\">" . htmlspecialchars($result['desc_long']) . "</p>" . "\n";
    $products .= "\t" . "<a href=\"#more\" class=\"more\">Read more...</a>" . "\n";
    $products .= "</li>" . "\n\n";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<title><?php