當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DBConnector::query方法代碼示例

本文整理匯總了PHP中DBConnector::query方法的典型用法代碼示例。如果您正苦於以下問題:PHP DBConnector::query方法的具體用法?PHP DBConnector::query怎麽用?PHP DBConnector::query使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DBConnector的用法示例。


在下文中一共展示了DBConnector::query方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: DBConnector

require_once 'DBConnector.class.php';
$dbcon = new DBConnector();
$remote = $_SERVER['REMOTE_ADDR'];
$isAllowed = false;
$newJSON = '{}';
$oldJSON = '';
if (isset($_REQUEST['json'])) {
    $oldJSON = $_REQUEST['json'];
    trace("db old: {$oldJSON}");
}
for ($t = 0; $t < 300; $t++) {
    //~ echo("waiting for db change...<br>");
    //~ $array = ['username' => 'stweil', 'quux' => 'baz'];
    //~ $newJSON = json_encode($array);
    $database = array();
    $table = $dbcon->query('select * from setting');
    $data = array();
    while ($row = $table->fetchArray(SQLITE3_ASSOC)) {
        array_push($data, $row);
    }
    $database['setting'] = $data;
    $table = $dbcon->query('select * from address');
    $data = array();
    while ($row = $table->fetchArray(SQLITE3_ASSOC)) {
        array_push($data, $row);
        $isAllowed = $isAllowed || $row['address'] == $remote;
    }
    if (!$isAllowed) {
        // Some unauthorized host tried to read the database.
        // Don't return any data.
        break;
開發者ID:BennySchindelhauer,項目名稱:PalMA,代碼行數:31,代碼來源:db.php

示例2: remember_user

 public static function remember_user($remember_token)
 {
     $db_connection = new DBConnector();
     $obj_query = $db_connection->query("SELECT userid FROM remember WHERE token = '" . hash('sha256', $remember_token) . "' and expires > " . time() . ";");
     if ($obj_query->num_rows == 1) {
         $obj = $obj_query->fetch_object();
         $_SESSION['user_logged_in'] = true;
         $_SESSION['user_id'] = $obj->userid;
         Account::$user_is_logged_in = true;
     }
 }
開發者ID:iekadou,項目名稱:lightpainting,代碼行數:11,代碼來源:Account.php

示例3: query

 /**
  * Execute the given SQL query.
  *
  * @param string $sql The SQL query to execute
  * @param int $errorLevel The level of error reporting to enable for the query
  * @return SS_Query
  */
 public function query($sql, $errorLevel = E_USER_ERROR)
 {
     return $this->connector->query($sql, $errorLevel);
 }
開發者ID:congaaids,項目名稱:silverstripe-framework,代碼行數:11,代碼來源:Database.php

示例4: DBConnector

 }
 //~ var_dump($_SERVER);
 $db = new DBConnector('palma-test.db');
 $db->resetTables();
 //~ http://stackoverflow.com/questions/1964233/does-sqlite3-support-a-trigger-to-automatically-update-an-updated-on-datetime
 //~ https://www.sqlite.org/lang_createtrigger.html
 // TODO: Test database triggers (can be used in db.php).
 //~ $db->createFunction('dbModifiedCallback', 'dbModifiedCallback', 0);
 // {AFTER | BEFORE} {DELETE | INSERT | UPDATE } ON table
 //~ $db->exec("CREATE TRIGGER dbchange AFTER UPDATE ON user
 //~ BEGIN
 //~ dbModifiedCallback();
 //~ END");
 //~ $db = new DBConnector('palma.db');
 echo "Tables=" . $db->querySingle('SELECT count(*) FROM sqlite_master WHERE type="table"') . "\n";
 var_dump($db->query("SELECT * from sqlite_master"));
 $address = $db->ipAddress();
 $db->addUser('testuser1', $address);
 //~ $db->addUser('testuser2', $address);
 //~ $db->addUser('testuser3', $address);
 //~ $db->addUser('testuser4', $address);
 $users = $db->getUsers();
 $db->enableUser('testuser1');
 var_dump($users);
 $db->delUser('haenger', $address);
 $db->delUser('ivwz', $address);
 $db->delUser('skrieg', $address);
 $db->delUser('testuser1', $address);
 $db->delUser('testuser2', $address);
 $db->delUser('testuser3', $address);
 $db->delUser('testuser4', $address);
開發者ID:gertiksxx,項目名稱:PalMA,代碼行數:31,代碼來源:DBConnector.class.php


注:本文中的DBConnector::query方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。