コード例 #1
0
ファイル: misc.inc.php プロジェクト: RavenB/nsedit
function get_db()
{
    global $authdb;
    $db = new SQLite3($authdb, SQLITE3_OPEN_READWRITE);
    $db->exec('PRAGMA foreign_keys = 1');
    return $db;
}
コード例 #2
0
ファイル: DbTask.php プロジェクト: siciarek/suggester
 public function mainAction()
 {
     $this->dbconf = Phalcon\DI::getDefault()->getConfig()->database;
     $file = $this->getDI()->getConfig()->dirs->config . DIRECTORY_SEPARATOR . 'schema' . DIRECTORY_SEPARATOR . $this->dbconf->adapter . '.sql';
     $this->schema = realpath($file);
     if ($this->schema === false) {
         throw new \Exception('Unsupported database adapter: ' . $this->dbconf->adapter);
     }
     echo "{$this->dbconf->adapter}\n";
     echo $this->dropDatabase();
     switch ($this->dbconf->adapter) {
         case 'mysql':
             echo $this->createDatabase();
             echo $this->loadSchema();
             echo $this->loadFixtures();
             break;
         case 'sqlite':
             $dbfile = $this->di->getConfig()->dirs->data . DIRECTORY_SEPARATOR . $this->di->get('config')->database->dbname . '.sqlite';
             $db = new SQLite3($dbfile);
             chmod($dbfile, 0664);
             $db->createFunction('MD5', 'md5');
             $db->exec(file_get_contents($this->schema));
             $db->exec(file_get_contents(preg_replace('/sqlite.sql$/', 'fixtures.sql', $this->schema)));
             break;
         default:
             throw new \Exception('Unsupported database adapter: ' . $this->dbconf->adapter);
             break;
     }
 }
コード例 #3
0
/**
* Checks which files of a directory are missing in a SQLite3 database and returns a list of them.
*
* @arg dir The directory for which to check
* @arg dbfile The file containing the database
* @arg table The table name of the database
* @arg col The column containing the filenames
* @arg enckey The encryption key used for the database
* @returns A list of files missing from the database, or an empty list
*/
function missing_files_from_directory($dir, $dbfile, $table, $col, $enckey = NULL)
{
    $missing = array();
    $dirscan = scandir($dir, SCANDIR_SORT_ASCENDING);
    if ($dirscan == false) {
        // Either $dir is not a directory or scandir had no success
        return $missing;
    }
    try {
        if (is_string($enckey)) {
            $db = new SQLite3($dbfile, SQLITE3_OPEN_READONLY, $enckey);
        } else {
            $db = new SQLite3($dbfile, SQLITE3_OPEN_READONLY);
        }
    } catch (Exception $e) {
        // Database could not be opened; return empty array
        return $missing;
    }
    foreach ($dirscan as $file) {
        if (is_dir($file) || is_link($file)) {
            // Filtering out directories (. and ..) and links {
            continue;
        }
        if ($db->querySingle("SELECT EXISTS(SELECT * FROM " . $table . " WHERE " . $col . " = '" . SQLite3::escapeString($file) . "');")) {
            // if an entry exists, returns TRUE, otherwise FALSE; invalid or failing queries return FALSE
            continue;
        }
        // entry does not exist; add to array
        $missing[] = $file;
    }
    $db->close();
    sort($missing, SORT_LOCALE_STRING | SORT_FLAG_CASE);
    return $missing;
    // sort based on the locale, case-insensitive
}
コード例 #4
0
/**
 * Get a list of venues which are whitin $distance of location ($lat, long)
 * and have a category similar to $keyword
 * 
 * returns list of venue information
 */
function locationKeywordSearch($lat, $long, $keyword, $distance, $limit = 25)
{
    $_SESSION['lat'] = $lat;
    $_SESSION['long'] = $long;
    $_SESSION['keyword'] = $keyword;
    global $databaseName;
    $db = new SQLite3($databaseName);
    // Attach methods haversineGreatCircleDistance,stringSimilarity to
    // Database engine so that we can use them in our query
    $db->createFunction("DISTANCE", "haversineGreatCircleDistance");
    $db->createFunction("SIMILARITY", "stringSimilarity");
    // Search query: get venue information for venues close to location, with categories most similar to the keyword/phrase
    $statement = $db->prepare('SELECT venueId, name, lat, long, categories, address, DISTANCE(lat, long) as distance, SIMILARITY(categories)' . " as similarity FROM Venues WHERE distance < :dist ORDER BY similarity DESC LIMIT :limit");
    // Bind some parameters to the query
    $statement->bindValue(':limit', $limit);
    $statement->bindValue(':dist', $distance, SQLITE3_INTEGER);
    // Obtain the venues from the db and put them in a list
    $qry = $statement->execute();
    $venues = [];
    while ($venue = $qry->fetchArray()) {
        $venues[] = $venue;
    }
    $db->close();
    return $venues;
}
コード例 #5
0
ファイル: admin.php プロジェクト: kbeswick/library
function check_links()
{
    //Before checking anything, check if laurentian.concat.ca is resolving.
    $catalogue_link = fopen("http://laurentian.concat.ca/", "r");
    if (!$catalogue_link) {
        die("There may be a problem with laurentian.concat.ca so this process is going to halt. If this persists, contact Kevin Beswick");
    }
    fclose($catalogue_link);
    //Check all links from database, if active, leave alone, if not active, delete them.
    $db_session = new SQLite3('reserves.db');
    $query = "SELECT bookbag_id from reserve";
    $results = $db_session->query($query) or die($db_session->lastErrorMsg());
    $begin_link = "http://laurentian.concat.ca/opac/extras/feed/bookbag/opac/";
    $end_link = "?skin=lul";
    $count = 0;
    while ($row = $results->fetchArray()) {
        $file = fopen($begin_link . $row["bookbag_id"] . $end_link, "r");
        if (!$file) {
            //remove from list
            $query = "DELETE from reserve where bookbag_id = " . $row["bookbag_id"];
            $db_session->exec($query) or die("not working... " . $db_session->lastErrorMsg());
            $count++;
        }
        fclose($file);
    }
    echo "Done removing dead links... " . $count . " were removed.";
}
コード例 #6
0
ファイル: edit_car_php.php プロジェクト: trullarn/php
function getCars($query)
{
    $db = new SQLite3('car.db');
    $results = $db->query($query);
    echo "<table class=\"search-results\">";
    echo "<th>Reg nummer</th>";
    echo "<th>Märke</th>";
    echo "<th>Modell</th>";
    echo "<th>Pris</th>";
    echo "<th>Antal mil</th>";
    echo "<th>Årsmodell</th>";
    echo "<th>Redigera</th>";
    $numRows = 0;
    while ($row = $results->fetchArray()) {
        $numRows++;
    }
    if ($numRows === 0) {
        echo "<tr><td colspan=\"8\">Inga resultat för: \"" . $_POST['search'] . "\"</td></tr>";
    } else {
        while ($row = $results->fetchArray()) {
            echo "<tr>\n                <td class=\"car-regnr\"><a data-id=\"{$row['id']}\" href=\"#\" class=\"car-info\">{$row['regnr']}</td>\n                <td class=\"car-brand\">{$row['brand']}</td>\n                <td class=\"car-model\">{$row['model']}</td>\n                <td class=\"car-price\">{$row['price']}</td>\n                <td class=\"car-milage\">{$row['milage']}</td>\n                <td class=\"car-year\">{$row['year']}</td>\n                <td class=\"car-edit-link\"><a data-id=\"{$row['id']}\" href=\"#\" class=\"car-info\">Redigera</a></td>\n                </tr>";
        }
        echo "</table>";
    }
    $db->close();
}
コード例 #7
0
ファイル: anubis.php プロジェクト: bhargavz/WIPSTER
function anubisFILE($idmd5, $fileName)
{
    #Execute the Python Script
    #python /var/www/anubis/submit_to_anubis.py /var/www/mastiff/MD5/filename.VIR
    $command = 'python /var/www/anubis/submit_to_anubis.py -u ' . $anubisUser . ' -p ' . $anubisPass . ' "/var/www/mastiff/' . $idmd5 . '/' . $fileName . '"';
    $output = shell_exec($command);
    $anubisRes['out'] = $output;
    $pattern = '/https?\\:\\/\\/[^\\" ]+/i';
    preg_match($pattern, $output, $matches);
    #echo '<pre>';
    #	echo '$matches: ';
    #	var_dump($matches);
    #echo '</pre>';
    $anubisLink = $matches[0];
    $anubisLink = strstr($anubisLink, "\n", true);
    $anubisRes['link'] = $anubisLink;
    #Update the Database
    $db = new SQLite3('../mastiff/mastiff.db');
    $result = $db->exec('UPDATE mastiff SET anubis = "' . $anubisLink . '" WHERE md5 = "' . $idmd5 . '"');
    if (!$result) {
        $anubisRes['db'] = $db->lastErrorMsg();
    } else {
        $anubisRes['db'] = $db->changes() . ' Record updated successfully.';
    }
    return $anubisRes;
}
コード例 #8
0
ファイル: converter.php プロジェクト: qwexak/parking-paradox
function ConvertDB($fname)
{
    //	echo "=> {$fname}\n";
    if (!file_exists($fname)) {
        exit(10);
    }
    $db = new SQLite3('base.sqlite');
    $db->exec("pragma synchronous = off;");
    $tablename = pathinfo($fname, PATHINFO_FILENAME);
    $pdx = new Paradox();
    $pdx->Open($fname);
    $db->exec(createdb_schema($tablename, $pdx->GetSchema()));
    $db->exec('DELETE FROM ' . $tablename);
    if ($records = $pdx->GetNumRows()) {
        $schema = $pdx->GetSchema();
        //		print_r($schema);
        for ($rec = 0; $rec < $records; $rec++) {
            $pdx->GetRow($rec);
            //			if ($rec > 2) break;
            $query = 'INSERT INTO `' . $tablename . '` VALUES (';
            $values = '';
            foreach ($pdx->row as $fieldName => $value) {
                switch ($schema[$fieldName]['type']) {
                    case 1:
                        $value = brackets(iconv('windows-1251', 'UTF-8', $value));
                        break;
                    case 2:
                        $value = brackets($pdx->GetStringfromDate($value));
                        break;
                    case 21:
                        $value = brackets($pdx->GetStringfromTimestamp($value));
                        break;
                    case 4:
                        $value = (int) $value;
                        break;
                    case 6:
                        $value = (double) $value;
                        break;
                    case 9:
                        $value = (int) $value;
                        break;
                    case 13:
                        $value = "X" . brackets(bin2hex($value));
                        break;
                    default:
                        $value;
                        break;
                }
                $values .= $value . ', ';
                //				print "{$schema[$fieldName]['type']}\t{$fieldName}\t{$value}\n";
            }
            $values = rtrim($values, ', ');
            $query .= $values . ");\n";
            //			print trim($query).PHP_EOL;
            $db->exec($query);
        }
        return true;
    }
    $pdx->Close();
}
コード例 #9
0
    /**
     * Create Tables needed for storing information about apps.
     *
     * @throws DBAppsException
     *  If a create table query fails.
     */
    protected function createTables()
    {
        $sqls = array(<<<'EOF'
-- Table for listing top free apps from google.
CREATE TABLE IF NOT EXISTS topApps
(
    package TEXT, -- The package name of the app.
    rank INT, -- The rank of the app in the top apps list.
    PRIMARY KEY(package)
);
EOF
, <<<'EOF'
-- Table for listing all apps from google.
CREATE TABLE IF NOT EXISTS Apps
(
    package TEXT, -- The package name of the app.
    title TEXT, -- The title of the app (human readable).
    author TEXT, -- The author of the app.
    description TEXT, -- The description text of the app.
    PRIMARY KEY(package)
);
EOF
);
        foreach ($sqls as $sql) {
            if ($this->db->query($sql) === FALSE) {
                throw new DBAppsException(_('Failed to create tables.'));
            }
        }
    }
コード例 #10
0
ファイル: DB.php プロジェクト: jlaso/simple-stats
 /**
  * @param StatsModel $model
  * @param string $data
  * @param int $count
  * @return \SQLite3Result
  */
 public function insertData(StatsModel $model, $data, $count = 1)
 {
     $statement = $this->conn->prepare(sprintf("INSERT INTO `%s` (`date`, `count`, `data`) VALUES (%d, :count, :data);", $model->getEvent(), intval(date('U'))));
     $statement->bindValue(':data', $data, SQLITE3_TEXT);
     $statement->bindValue(':count', $count, SQLITE3_INTEGER);
     return $statement->execute();
 }
コード例 #11
0
ファイル: Helper.php プロジェクト: PisaCoderDojo/dojo-wp-site
 public static function getDB()
 {
     $con = new SQLite3('db/newsdb.db');
     $con->exec('PRAGMA foreign_keys = ON;');
     return $con;
     #return new SQLite3('../sqlite/newsdb.db.new');
 }
コード例 #12
0
function caching($comics_id, $zip_path, $image_ext)
{
    $comic = zip_open($zip_path);
    if (!is_resource($comic)) {
        die("[ERR]ZIP_OPEN : " . $zip_path);
    }
    $inzip_path = "";
    $count = 0;
    $files = null;
    $db = new SQLite3(DB);
    $db->exec("BEGIN DEFERRED;");
    while (($entry = zip_read($comic)) !== false) {
        $inzip_path = zip_entry_name($entry);
        $cache_name = md5($zip_path . "/" . $inzip_path) . '.' . get_ext($inzip_path);
        // 画像か否か
        if (!is_image($inzip_path, $image_ext)) {
            continue;
        }
        $data = zip_entry_read($entry, zip_entry_filesize($entry));
        $filepath = CACHE . '/' . $cache_name;
        file_put_contents($filepath, $data);
        $count++;
        query("INSERT INTO images (comics_id, page, filepath) VALUES (" . $comics_id . ", " . $count . ", '" . $filepath . "')", $db);
    }
    zip_close($comic);
    query("UPDATE comics SET pages = " . $count . " WHERE id = " . $comics_id, $db);
    $db->exec("COMMIT;");
}
コード例 #13
0
 public function tearDown()
 {
     $sql = 'DELETE FROM merchants';
     self::$dbConnection->query($sql);
     $sql = 'DELETE FROM transactions';
     self::$dbConnection->query($sql);
 }
コード例 #14
0
 /**
  * Cleans entries from journal.
  * @param  array  $conditions
  * @return array of removed items or NULL when performing a full cleanup
  */
 public function clean(array $conditions)
 {
     if (!empty($conditions[Cache::ALL])) {
         $this->database->exec('DELETE FROM CACHE;');
         return;
     }
     $query = array();
     if (!empty($conditions[Cache::TAGS])) {
         $tags = array();
         foreach ((array) $conditions[Cache::TAGS] as $tag) {
             $tags[] = "'" . $this->database->escapeString($tag) . "'";
         }
         $query[] = 'tag IN(' . implode(', ', $tags) . ')';
     }
     if (isset($conditions[Cache::PRIORITY])) {
         $query[] = 'priority <= ' . (int) $conditions[Cache::PRIORITY];
     }
     $entries = array();
     if (!empty($query)) {
         $query = implode(' OR ', $query);
         $result = $this->database->query("SELECT entry FROM cache WHERE {$query}");
         if ($result instanceof SQLiteResult) {
             while ($entry = $result->fetchSingle()) {
                 $entries[] = $entry;
             }
         } else {
             while ($entry = $result->fetchArray(SQLITE3_NUM)) {
                 $entries[] = $entry[0];
             }
         }
         $this->database->exec("DELETE FROM cache WHERE {$query}");
     }
     return $entries;
 }
コード例 #15
0
    public function OpenLogFile()
    {
        $db = null;
        $filename = $this->logdir . "/" . $this->logfile;
        if (!file_exists($this->logdir)) {
            mkdir($this->logdir, 0755, true);
        }
        $db = new SQLite3($filename);
        $sql = <<<SQL
CREATE TABLE IF NOT EXISTS account_attempt (
  time_attempted date not null default CURENT_TIMESTAMP,
  username text not null default '',
  email text not null default '',
  ip text not null default '',
  trigger text not null default '',
  confidence float not null default 0.0,
  accepted text default 'Y',
  verified text default 'N',
  primary key (time_attempted, username, email, ip)
)
SQL;
        $db->exec($sql);
        $sql = <<<IDXSQL
CREATE INDEX IF NOT EXISTS account_verification
ON account_attempt (accepted, verified)
IDXSQL;
        $db->exec($sql);
        return $db;
    }
コード例 #16
0
function handle_admin()
{
    if (empty($_POST['admin_account']) == false && empty($_POST['admin_password']) == false) {
        $account = $_POST['admin_account'];
        $password = md5($_POST['admin_password']);
        //password: ccc95
        $file_path = "../sqlite/books_web.s3db";
        if (file_exists($file_path)) {
            $link = new SQLite3($file_path);
            $sql_cmd = "SELECT password FROM root_account WHERE password='******'";
            $result = $link->query($sql_cmd);
            $i = 0;
            $row = array();
            while ($res = $result->fetchArray(SQLITE3_ASSOC)) {
                $row[$i]['password'] = $res['password'];
                $i++;
            }
            if (count($row) != 0) {
                $_SESSION['root'] = "root";
                return "admin login success.";
            } else {
                return "admin login failed.";
            }
            $link->close();
        } else {
            return "cannot link database.";
        }
    } else {
        return "post error";
    }
}
コード例 #17
0
function main()
{
    global $G;
    message("PHP testing sandbox (%s) version %s", $G['ME'], VERSION);
    try {
        $db = new SQLite3(DATABASE);
        $db->exec('DROP TABLE IF EXISTS t');
        $db->exec('CREATE TABLE t (a, b, c)');
        message('Table t sucessfully created');
        $sth = $db->prepare('INSERT INTO t VALUES (?, ?, ?)');
        $sth->bindValue(1, 'a');
        $sth->bindValue(2, 'b');
        $sth->bindValue(3, 'c');
        $sth->execute();
        $sth->bindValue(1, 1);
        $sth->bindValue(2, 2);
        $sth->bindValue(3, 3);
        $sth->execute();
        $sth->bindValue(1, 'one');
        $sth->bindValue(2, 'two');
        $sth->bindValue(3, 'three');
        $sth->execute();
        $sth = $db->prepare('SELECT * FROM t');
        $result = $sth->execute();
        while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
            message('%s, %s, %s', $row['a'], $row['b'], $row['c']);
        }
    } catch (Exception $e) {
        message($e->getMessage());
    }
}
コード例 #18
0
ファイル: lib.mbtiles.php プロジェクト: ndpgroup/fp-legacy
function get_mbtiles_data($file_path)
{
    $db_mbtiles = new SQLite3($file_path);
    // Min Zoom and Max Zoom
    $zoom_range_query = "select min(zoom_level), max(zoom_level) from tiles";
    $zoom_range_results = $db_mbtiles->query($zoom_range_query);
    $zoom_range = $zoom_range_results->fetchArray();
    $min_zoom = $zoom_range[0];
    $max_zoom = $zoom_range[1];
    // Get zoom, column, and row for each tile
    $query = "select zoom_level, avg(tile_column), avg(tile_row) from tiles group by zoom_level";
    $results = $db_mbtiles->query($query);
    $rows = array();
    while ($row = $results->fetchArray()) {
        $rows[] = $row;
    }
    $center_tile = $rows[floor(0.5 * count($rows))];
    $center_tile_zoom = $center_tile[0];
    $center_tile_x = floor($center_tile[1]);
    // Column
    $center_tile_y = round(pow(2, $center_tile_zoom) - $center_tile[2] - 1);
    // Converted Row
    $mbtiles_data = array("min_zoom" => $min_zoom, "max_zoom" => $max_zoom, "center_coordinates" => array("zoom" => $center_tile_zoom, "x" => intval($center_tile_x), "y" => intval($center_tile_y)));
    return $mbtiles_data;
}
コード例 #19
0
function cleanup_listeners_othermounts($maxagelimitstamp_othermounts, $fingerprint, $mountpoint)
{
    $db = new SQLite3('load.db');
    $db->busyTimeout(100);
    $db->exec("DELETE FROM t_listeners WHERE timestamp < {$maxagelimitstamp_othermounts} AND fingerprint = '{$fingerprint}' AND mountpoint != '{$mountpoint}'");
    $db->close();
}
コード例 #20
0
function getEvents()
{
    global $db;
    $token = trim(file_get_contents('config/token.txt'));
    $mainPage = pullUrl("https://techspring.nationbuilder.com/api/v1/sites/v2/pages/events?starting=" . date("Y-m-d") . "&access_token=" . $token . "");
    $obj = json_decode($mainPage);
    //echo "<pre>" . json_encode($obj, JSON_PRETTY_PRINT) . "</pre>";
    if ($db = new SQLite3('local_db.sql')) {
        $q = @$db->query('CREATE TABLE IF NOT EXISTS events (eid INTEGER, start_time TEXT, end_time TEXT, name TEXT, description TEXT, PRIMARY KEY(eid))');
        $q = @$db->query('CREATE TABLE IF NOT EXISTS rsvp (eid INTEGER, uid INTEGER)');
    }
    foreach ($obj->results as $eventObj) {
        echo "<br/>{$eventObj->id} - {$eventObj->name} - {$eventObj->start_time} - {$eventObj->end_time} - {$eventObj->intro} <br />";
        $startTime = strtotime($eventObj->start_time);
        $endTime = strtotime($eventObj->end_time);
        echo "Date: " . date("l, F jS", $startTime);
        echo "<br />Time:" . date("g:i a", $startTime) . " - " . date("g:i a", $endTime) . "<br />";
        @$db->query("INSERT OR IGNORE INTO `events` (eid, start_time, end_time, name, description) VALUES " . "('" . $eventObj->id . "'," . "'" . $eventObj->start_time . "'," . "'" . $eventObj->end_time . "'," . "'" . $eventObj->name . "'," . "'" . $eventObj->intro . "');");
    }
    $eventRes = @$db->query("SELECT * FROM `events`");
    while ($event = $eventRes->fetchArray()) {
        $json = pullUrl("https://techspring.nationbuilder.com/api/v1/sites/v2/pages/events/" . $event['eid'] . "/rsvps?limit=10&__proto__=&access_token=" . $token);
        $rsvpData = json_decode($json);
        foreach ($rsvpData->results as $rsvp) {
            @$db->query("INSERT OR IGNORE INTO `rsvp` (eid, uid) VALUES ('" . $event['eid'] . "','" . $rsvp->person_id . "')");
        }
    }
}
コード例 #21
0
 public function read($params, AccountWriter $writer)
 {
     $args = new FormattedArgumentMap($params);
     $folder = $args->opt("i", "plugins/SimpleAuth");
     if (!is_dir($folder)) {
         throw new \InvalidArgumentException("Input database {$folder} not found or is not a directory");
     }
     $path = rtrim($folder, "/\\") . "/players.db";
     if (!is_file($path)) {
         return;
     }
     $this->setStatus("Opening database");
     $db = new \SQLite3($path);
     $result = $db->query("SELECT COUNT(*) AS cnt FROM players");
     $total = $result->fetchArray(SQLITE3_ASSOC)["cnt"];
     $result->finalize();
     $this->setStatus("Preparing data");
     $result = $db->query("SELECT name,registerdate,logindate,lastip,hash FROM players");
     $i = 0;
     while (is_array($row = $result->fetchArray(SQLITE3_ASSOC))) {
         $i++;
         $info = AccountInfo::defaultInstance($row["name"], $this->defaultOpts);
         $info->lastIp = $row["lastip"];
         $info->registerTime = $row["registerdate"];
         $info->lastLogin = $row["logindate"];
         $info->passwordHash = hex2bin($row["hash"]);
         $writer->write($info);
         $this->setProgress($i / $total);
     }
     $db->close();
 }
コード例 #22
0
function resetHighscore()
{
    $db = new SQLite3('pacman.db');
    $date = date('Y-m-d h:i:s', time());
    $db->exec('DROP TABLE IF EXISTS highscore');
    createDataBase($db);
}
コード例 #23
0
 /**
  * create a new database
  *
  * @param string $name    name of the database that should be created
  * @param array  $options array with charset info
  *
  * @return mixed MDB2_OK on success, a MDB2 error on failure
  * @access public
  */
 function createDatabase($name, $options = array())
 {
     $datadir = OC_Config::getValue("datadirectory", OC::$SERVERROOT . "/data");
     $db = $this->getDBInstance();
     if (PEAR::isError($db)) {
         return $db;
     }
     $database_file = $db->_getDatabaseFile($name);
     if (file_exists($database_file)) {
         return $db->raiseError(MDB2_ERROR_ALREADY_EXISTS, null, null, 'database already exists', __FUNCTION__);
     }
     $php_errormsg = '';
     $database_file = "{$datadir}/{$database_file}.db";
     $handle = new SQLite3($database_file);
     if (!$handle) {
         return $db->raiseError(MDB2_ERROR_CANNOT_CREATE, null, null, isset($php_errormsg) ? $php_errormsg : 'could not create the database file', __FUNCTION__);
     }
     //sqlite doesn't support the latin1 we use
     //         if (!empty($options['charset'])) {
     //             $query = 'PRAGMA encoding = ' . $db->quote($options['charset'], 'text');
     //             $handle->exec($query);
     //         }
     $handle->close();
     return MDB2_OK;
 }
コード例 #24
0
ファイル: dbhelper.php プロジェクト: blckshrk/DressYourself
 public function findClotheById($id)
 {
     $db = new SQLite3($this->dbFileName);
     $data = $db->query(self::QUERY_BASE . ' WHERE ID_clothes = ' . $id);
     $arrayData = $this->SQLite2JSON($data);
     $db->close();
     return json_encode($arrayData);
 }
コード例 #25
0
ファイル: DbSqLite3.php プロジェクト: radekstepan/Clubhouse
 /**
  * Run a query on the database;
  * @param string $query
  * @return boolean TRUE on success
  */
 public function query($query)
 {
     $sqlite = new SQLite3($this->path);
     // escape query
     $query = $sqlite->escapeString($query);
     // run it and return result
     return $sqlite->query($query);
 }
コード例 #26
0
 protected function InitDB()
 {
     $handle = new SQLite3($this->filename);
     $handle->exec("PRAGMA synchronous = OFF");
     $handle->exec("PRAGMA journal_mode = OFF");
     $handle->exec("PRAGMA cache_size = 1");
     return $handle;
 }
コード例 #27
0
ファイル: StorageTest.php プロジェクト: hyperlator/Sismo
 public function setUp()
 {
     $app = (require __DIR__ . '/../../../../src/app.php');
     $this->path = sys_get_temp_dir() . '/sismo.db';
     @unlink($this->path);
     $this->db = new \SQLite3($this->path);
     $this->db->busyTimeout(1000);
     $this->db->exec($app['db.schema']);
 }
コード例 #28
0
ファイル: score.php プロジェクト: joksnet/js-games
function init_db()
{
    $exists = file_exists('score.db');
    $sqlite = new SQLite3('score.db');
    if (!$exists) {
        $sqlite->exec('CREATE TABLE score (name text, points int, time int)');
    }
    return $sqlite;
}
コード例 #29
0
ファイル: DbHandler.php プロジェクト: krixisLv/SimpleChat
 protected static function initializeSQLiteDbTables($location)
 {
     $sqlite = new SQLite3($location);
     $tables_setup = DbConfig::getDbTablesSetup();
     foreach ($tables_setup as &$query) {
         $sqlite->exec($query);
     }
     unset($table);
 }
コード例 #30
-1
ファイル: PLENTY_class.php プロジェクト: supertorti/FRAMEWORK
 public function doAuthenticication()
 {
     $LoginData = array(array('Username' => $this->SOAP_USERNAME, 'Userpass' => $this->SOAP_USERPASS));
     // Nun erfolgt der eigentliche Call der Funtion / GetAuthentificationToken
     try {
         $oResponse = $this->__soapCall('GetAuthentificationToken', $LoginData);
     } catch (SoapFault $sf) {
         print_r("Es kam zu einem Fehler beim Call GetAuthentificationToken<br>");
         print_r($sf->getMessage());
     }
     if ($oResponse->Success == true) {
         // Der Abruf hat erfolgreich UserID und Token zurückgeliefert.
         // Der Token ist bis 00:00:00 Uhr eines Tages gültig und muss daher nicht
         $UserID = $oResponse->UserID;
         $Token = $oResponse->Token;
         // Bei erfolg ab in die Datenbank
         $timestamp = time();
         $db = new SQLite3(APPLICATION_PATH . "/FRAMEWORK/STORAGE/soapdb.db");
         $db->exec("INSERT INTO token (id, token, timestamp, user) VALUES ('{$UserID}', '{$Token}', '{$timestamp}', '{$this->SOAP_USERNAME}')");
         // Mit diesen Daten kann nun der SOAP-Header erzeugt und hinzugefügt werden
         $this->createSoapHeader($UserID, $Token);
     } else {
         print_r("Es ist folgender Fehler aufgetreten : " . $oResponse->ErrorMessages->item[0]->Message);
     }
 }