当前位置: 首页>>代码示例>>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;未经允许,请勿转载。