当前位置: 首页>>代码示例>>PHP>>正文


PHP SQLite3::close方法代码示例

本文整理汇总了PHP中SQLite3::close方法的典型用法代码示例。如果您正苦于以下问题:PHP SQLite3::close方法的具体用法?PHP SQLite3::close怎么用?PHP SQLite3::close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SQLite3的用法示例。


在下文中一共展示了SQLite3::close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getCars

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();
}
开发者ID:trullarn,项目名称:php,代码行数:26,代码来源:edit_car_php.php

示例2: createDatabase

 /**
  * 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;
 }
开发者ID:jaeindia,项目名称:ownCloud-Enhancements,代码行数:34,代码来源:sqlite3.php

示例3: locationKeywordSearch

/**
 * 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;
}
开发者ID:wardlawp,项目名称:VenueWebsite,代码行数:31,代码来源:SearchMethods.php

示例4: read

 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();
 }
开发者ID:PEMapModder,项目名称:HereAuth,代码行数:31,代码来源:SimpleAuthSQLite3AccountReader.php

示例5: cleanup_listeners_othermounts

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();
}
开发者ID:xxaxxelxx,项目名称:xx_loadbalancer,代码行数:7,代码来源:functions.php

示例6: missing_files_from_directory

/**
* 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
}
开发者ID:jankohoener,项目名称:sqlite-scripts,代码行数:45,代码来源:missingfiles.php

示例7: handle_admin

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='{$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";
    }
}
开发者ID:peter279k,项目名称:phpunit-test,代码行数:31,代码来源:handle_admin3.php

示例8: close

 /**
  * Zamknięcie połączenia z bazą danych
  *
  */
 public function close()
 {
     if (!empty($this->dbHandle)) {
         $this->dbHandle->close();
     }
     return true;
 }
开发者ID:PhanQuocTrung,项目名称:WeatherStation,代码行数:11,代码来源:SQLiteWrapper.php

示例9: save_pois

function save_pois($jsonStr, $dbname)
{
    //create or open the channel database
    $db = new SQLite3($dbname, SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE);
    //create the POIs table
    $db->query("CREATE TABLE IF NOT EXISTS POIsM (id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT, description TEXT, phoneNumber TEXT, homepage TEXT, iconURL TEXT, thumbnailURL TEXT, imageURL TEXT,\n                videoURL TEXT, soundURL TEXT, modelURL TEXT, latitude REAL, longitude REAL, altitude REAL) ;");
    $db->query("DELETE FROM POIsM;");
    //required because we bulk-replace all POIs on updates to the channel
    $db->query("UPDATE SQLITE_SEQUENCE SET seq='0' WHERE name='POIsM';");
    //reset the id count to start from 1 again; Else, the id count starts from the previously used highest id for the table
    //Decode the json string to UTF-8 encoding as "json_decode" only works for UTF-8 encoding
    $poisJson = json_decode(utf8_decode($jsonStr));
    $objects = $poisJson->pois;
    //parse the input json for POI information
    foreach ($objects as $obj) {
        $description = "";
        $phoneNumber = "";
        $icon = "";
        $thumbnail = "";
        print_r($obj);
        $homepage = "";
        $imageUrl = "";
        $movieUrl = "";
        $soundUrl = "";
        //Check if attributes needed for POI are present in JSON
        if (isset($obj->description)) {
            $description = $obj->description;
        }
        if (isset($obj->phoneNumber)) {
            $phoneNumber = $obj->phoneNumber;
        }
        if (isset($obj->iconURL)) {
            $icon = $obj->iconURL;
        } else {
            $icon = "http://channels.excel.junaio.com/resources/icon_thumbnail.png";
        }
        if (isset($obj->thumbnailURL)) {
            $thumbnail = $obj->thumbnailURL;
        } else {
            $thumbnail = "http://channels.excel.junaio.com/resources/icon_thumbnail.png";
        }
        if (isset($obj->homepage)) {
            $homepage = $obj->homepage;
        }
        if (isset($obj->imageURL)) {
            $imageUrl = $obj->imageURL;
        }
        if (isset($obj->video)) {
            $movieUrl = $obj->video;
        }
        if (isset($obj->sound)) {
            $soundUrl = $obj->sound;
        }
        //insert each POI to the db
        $query = "INSERT INTO POIsM (title, description, phoneNumber, homepage, iconURL, thumbnailURL, imageURL, videoURL,\n        soundURL, modelURL, latitude, longitude, altitude) VALUES ('" . $obj->title . "', '" . $description . "',\n        '" . $phoneNumber . "', '" . $homepage . "', '" . $icon . "', '" . $thumbnail . "', '" . $imageUrl . "', '" . $movieUrl . "', '" . $soundUrl . "', '', '" . $obj->latitude . "', '" . $obj->longitude . "', '" . $obj->altitude . "');";
        $db->query($query);
    }
    $db->close();
}
开发者ID:Theekshana,项目名称:junaio-quickstarts,代码行数:59,代码来源:csv2sqlite.php

示例10: disconnect

 /**
  * Disconnects from database.
  *
  * @return void
  */
 public function disconnect()
 {
     if ($this->connected !== TRUE) {
         return;
     }
     $this->sqlite3->close();
     $this->connected = FALSE;
 }
开发者ID:rubendgr,项目名称:lunr,代码行数:13,代码来源:SQLite3Connection.php

示例11: findClotheById

 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);
 }
开发者ID:blckshrk,项目名称:DressYourself,代码行数:8,代码来源:dbhelper.php

示例12: updateUserMeetingWithPoints

function updateUserMeetingWithPoints($userlogin, $meetingname, $points)
{
    $db = new SQLite3("db/db.sqlite3");
    if (!$db) {
        echo $db->lastErrorMsg();
        return false;
    }
    $sql = "UPDATE userscurves SET points=\"{$points}\" WHERE userlogin='{$userlogin}' AND meetingname='{$meetingname}'";
    $ret = $db->exec($sql);
    if ($ret > 0) {
        $db->close();
        return true;
    } else {
        $db->close();
        return false;
    }
}
开发者ID:atchyutn,项目名称:Appointment,代码行数:17,代码来源:updateFunctions.php

示例13: getAll

function getAll()
{
    $db = new SQLite3(DB_FILENAME);
    $result = $db->query("SELECT * FROM iventory");
    while ($record = $result->fetchArray()) {
        print $record['number'] . "<br />";
    }
    $db->close();
}
开发者ID:sc4brain,项目名称:ManageInventory,代码行数:9,代码来源:getinfo.php

示例14: acctstart

function acctstart($input)
{
    require_once "settings.php";
    $input = $input;
    $delimiter1 = "The new session";
    $delimiter2 = "has been created";
    $pos1 = strpos($input, $delimiter1) + strlen($delimiter1) + 2;
    $pos2 = strpos($input, $delimiter2) - 2;
    $sstrlen = $pos2 - $pos1;
    $sessid = substr($input, $pos1, $sstrlen);
    exec($vpncmd . " " . $softetherip . " /SERVER /HUB:" . $hubname . " /PASSWORD:" . $apipass . " /CSV /CMD SessionGet " . $sessid, $SessionGet);
    if (strpos($SessionGet[0], "rror occurred") != FALSE) {
        die("Error - SessionGet resulted in error");
    }
    foreach ($SessionGet as $line) {
        list($key, $val) = explode(",", $line, 2);
        $result[$key] = $val;
    }
    $recheck = 0;
    dhcptest:
    sleep(2);
    exec($vpncmd . " " . $softetherip . " /SERVER /HUB:" . $hubname . " /PASSWORD:" . $apipass . " /CSV /CMD IpTable", $IpTable);
    $ok = 0;
    foreach ($IpTable as $line) {
        if (strpos($line, $sessid)) {
            if (strpos($line, "DHCP")) {
                list(, $key, $val) = explode(",", $line);
                list($framedip) = explode(" ", $val);
                #$result2[$key] = $val;
                $ok = 1;
            }
        }
    }
    if ($ok == 0) {
        if ($recheck == 4) {
            die("Error - could not find session in retrived IpTable data");
        }
        sleep(2);
        $recheck = $recheck + 1;
        goto dhcptest;
    }
    $db = new SQLite3($database);
    $db->exec('CREATE TABLE IF NOT EXISTS sessions (sessionid varchar(255), username varchar (255), clientip varchar (255), inputoctets varchar (255), ' . 'outputoctets varchar (255), framedip varchar (255), nasip varchar (255), nasport varchar (255), acctstarttime varchar (255), ' . 'acctsessiontime varchar (255), PRIMARY KEY(sessionid))');
    $query = $db->escapeString('INSERT OR REPLACE INTO sessions (sessionid, username, clientip, inputoctets, outputoctets, framedip, nasip, nasport, acctstarttime, acctsessiontime) VALUES ("' . $sessid . '","' . $result["User Name (Authentication)"] . '","' . $result["Client IP Address"] . '",NULL,NULL,"' . $framedip . '","' . $result["Server IP Address (Reported)"] . '","' . $result["Server Port (Reported)"] . '","' . $result["Connection Started at"] . '",NULL)');
    $db->exec($query);
    $sessid = $db->escapeString($sessid);
    $results = $db->querySingle("SELECT * FROM sessions WHERE sessionid = '" . $sessid . "'", true);
    $tmpfname = tempnam($tmpdir, "acctstarttmp_");
    $handle = fopen($tmpfname, "w");
    $packet = "Service-Type = Framed-User" . "\n" . "Framed-Protocol = PPP" . "\n" . "NAS-Port = " . $results['nasport'] . "\n" . "NAS-Port-Type = Async" . "\n" . "User-Name = '" . $results['username'] . "'" . "\n" . "Calling-Station-Id = '" . $results['clientip'] . "'" . "\n" . "Called-Station-Id = '" . $results['nasip'] . "'" . "\n" . "Acct-Session-Id = '" . $sessid . "'" . "\n" . "Framed-IP-Address = " . $results['framedip'] . "\n" . "Acct-Authentic = RADIUS" . "\n" . "Event-Timestamp = " . time() . "\n" . "Acct-Status-Type = Start" . "\n" . "NAS-Identifier = '" . $results['nasip'] . "'" . "\n" . "Acct-Delay-Time = 0" . "\n" . "NAS-IP-Address = " . $results['nasip'] . "\n";
    fwrite($handle, $packet);
    fclose($handle);
    exec("radclient " . $radiussrv . ":" . $radiusport . " acct " . $radiuspass . " -f " . $tmpfname);
    unlink($tmpfname);
    $db->close();
}
开发者ID:bytepoet,项目名称:softether-radacct,代码行数:56,代码来源:acctstart.php

示例15: select

function select($query)
{
    $db = new SQLite3(DB);
    $results = $db->query($query);
    if (!$results) {
        $db->close();
        return false;
    }
    $data = array();
    $count = 0;
    while ($row = $results->fetchArray(SQLITE3_ASSOC)) {
        foreach ($row as $column => $r) {
            $data[$count][$column] = $r;
        }
        $count++;
    }
    $db->close();
    return $data;
}
开发者ID:undisputed-seraphim,项目名称:manga_server,代码行数:19,代码来源:sqlite.php


注:本文中的SQLite3::close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。