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


PHP DatabaseConnection::query方法代码示例

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


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

示例1: query

 /** @return DatabaseReader|string|array|void */
 public static function query($query, $args = null, $flags = 0)
 {
     if (!self::$default && self::$connectHandler) {
         self::$connectHandler[0]->{self::$connectHandler[1]}();
     }
     return self::$default->query($query, $args, $flags);
 }
开发者ID:cyantree,项目名称:grout,代码行数:8,代码来源:Database.php

示例2: destroySessions

 /**
  * @param string $userUid
  *
  * @return int Number of destroyed sessions.
  */
 public function destroySessions($userUid)
 {
     // Run two separate queries so we know exactly how many sessions are deleted.
     $destroyed = $this->connection->query('DELETE s FROM {sessions} s INNER JOIN {oxygen_session} os ON os.sid = s.sid  WHERE os.uid = :uid', array('uid' => $userUid), array('return' => Database::RETURN_AFFECTED));
     $this->connection->query('DELETE FROM {oxygen_session} WHERE uid = :uid', array('uid' => $userUid));
     return $destroyed;
 }
开发者ID:Briareos,项目名称:Oxygen,代码行数:12,代码来源:SessionManager.php

示例3: cleanup

 protected function cleanup()
 {
     // Test could have been skipped
     if (null !== $this->dbConnection) {
         foreach (array('apb_queue', 'apb_msg', 'apb_msg_chan', 'apb_sub', 'apb_chan') as $table) {
             $this->dbConnection->query("DELETE FROM {" . $table . "}");
         }
     }
 }
开发者ID:makinacorpus,项目名称:drupal-apubsub,代码行数:9,代码来源:MessageTest.php

示例4: testLastID

 public function testLastID()
 {
     require __DIR__ . '/config/database_test.php';
     $db = new DatabaseConnection($host, $database, $user, $password);
     $insert_result = $db->query("INSERT INTO characters (id, name, description, type, dead, stage, hp) \r\n\t\t\tVALUES ('9999', 'Carla', 'The swordmaster of Melee Island', 'pirate', 'false',  '4',  '87');");
     $actual = $db->lastID();
     $expected = '9999';
     $delete_result = $db->query("DELETE FROM characters WHERE id = '9999'");
     $this->assertNotEmpty($actual, 'Function LastID returning empty value. Check TestDatabaseConnection::lastID()');
     $this->assertEquals($expected, $actual, 'Function LastID not returning expected value. Check TestDatabaseConnection::lastID()');
 }
开发者ID:rafamalaga86,项目名称:gamerest,代码行数:11,代码来源:TestDatabaseConnection.php

示例5: useNonce

 /**
  * {@inheritdoc}
  */
 public function useNonce($nonce, $expiresAt)
 {
     if ($expiresAt < time()) {
         throw new Oxygen_Exception(Oxygen_Exception::NONCE_EXPIRED);
     }
     $cleanNonce = strtr($nonce, ['-' => '']);
     $nonceUsed = (bool) $this->connection->query('SELECT 1 FROM {oxygen_nonce} WHERE nonce = :nonce', [':nonce' => $cleanNonce])->fetchField();
     if ($nonceUsed) {
         throw new Oxygen_Exception(Oxygen_Exception::NONCE_ALREADY_USED);
     }
     $this->connection->query('INSERT INTO {oxygen_nonce} (nonce, expires) VALUES (:nonce, :expires)', [':nonce' => $cleanNonce, ':expires' => $expiresAt]);
 }
开发者ID:Briareos,项目名称:Oxygen,代码行数:15,代码来源:NonceManager.php

示例6: uniqid

 function __construct(DatabaseConnection $parent)
 {
     //echo "Opening Connection\n";
     if ($parent->is_transaction()) {
         $this->using_savepoints = true;
         $this->savepoint_name = 'transaction_' . uniqid();
         $parent->query('SAVEPOINT ' . pg_escape_identifier($this->savepoint_name));
     } else {
         $this->using_savepoints = false;
         $parent->query("START TRANSACTION");
     }
     $this->parent_connection = $parent;
 }
开发者ID:sandyman,项目名称:postgres-dbal,代码行数:13,代码来源:DatabaseTransaction.php

示例7: refreshUserList

 public function refreshUserList()
 {
     //assim evitamos a necessidade de consultar o banco a cada requisição de lista
     $dbconn = new DatabaseConnection('localhost', 'user', 'password');
     $results = $dbconn->query('select name from user');
     $this->setUserList(sort($results));
 }
开发者ID:atriches,项目名称:prova,代码行数:7,代码来源:questao3.php

示例8: delete

 /**
  * Delete the character with that ID
  * 
  * @throws StatusCodeException 404 if was not deleted
  *
  * @param DatabaseConnection database class instance
  * @param mixed ID number, could be a string or an int
  */
 public static function delete(DatabaseConnection $db, $id)
 {
     $success = $db->query('DELETE FROM characters WHERE id = ?;', [$id]);
     if (!$success) {
         throw new StatusCodeException(404);
     }
 }
开发者ID:rafamalaga86,项目名称:gamerest,代码行数:15,代码来源:Character.php

示例9: getUserList

 public function getUserList()
 {
     $dbconn = new DatabaseConnection('localhost', 'user', 'password');
     $results = $dbconn->query('select name from user');
     sort($results);
     return $results;
 }
开发者ID:hpazevedo,项目名称:Teste-BDR,代码行数:7,代码来源:index.php

示例10: getListaUsuario

 public function getListaUsuario($dbconn = null)
 {
     if (!isset($dbconn) || !$dbconn instanceof DatabaseConnection) {
         $dbconn = new DatabaseConnection('localhost', 'root', '');
     }
     $results = $dbconn->query('SELECT name FROM users');
     sort($results);
     return $results;
 }
开发者ID:rodrigopluz,项目名称:provaTecnica-BDR,代码行数:9,代码来源:index-3.php

示例11: submitComment

 public function submitComment()
 {
     $conn = new DatabaseConnection();
     if (!isset($_GET['replyid'])) {
         $sentence = 'CALL addComment(' . $_SESSION['bookid'] . ',' . $_SESSION['id'] . ",'" . $_POST['comment'] . "')";
     } else {
         $sentence = 'CALL addReply(' . $_SESSION['bookid'] . ',' . $_SESSION['id'] . ',' . $conn->quote($_POST['reply']) . ',' . $_GET['replyid'] . ')';
     }
     $conn->query($sentence);
 }
开发者ID:apexJCL,项目名称:mvc,代码行数:10,代码来源:comment.php

示例12: getUserList

 public function getUserList()
 {
     $server = "localhost";
     $user = "user";
     $password = "password";
     $dbconn = new DatabaseConnection($server, $user, $password);
     if ($dbconn->connect_error) {
         die("Conexão falhou: " . $dbconn->connection_error);
     } else {
         $results = $dbconn->query('select name from user');
         sort($results);
         return $results;
     }
 }
开发者ID:solangegamboa,项目名称:teste-php,代码行数:14,代码来源:questao3.php

示例13: getExtensions

 /**
  * @return array
  */
 private function getExtensions()
 {
     // Select all columns; 'filename' is the primary key.
     $query = "SELECT filename, name, type, owner, status, bootstrap, info FROM {system} WHERE type IN ('module', 'theme') ORDER BY filename ASC";
     $rows = $this->connection->query($query)->fetchAllAssoc('filename');
     $extensions = array();
     foreach ($rows as $row) {
         $info = unserialize($row->info);
         if ($info['hidden']) {
             continue;
         }
         // See default values in _system_rebuild_module_data().
         $extensions[$row->name] = ['filename' => $row->filename, 'type' => $row->type, 'slug' => $row->name, 'parent' => strlen($row->owner) ? $row->owner : null, 'enabled' => (bool) $row->status, 'name' => $info['name'], 'description' => $info['description'], 'package' => $info['package'], 'version' => $info['version'], 'required' => empty($info['required']) ? false : true, 'dependencies' => empty($info['dependencies']) ? array() : $info['dependencies'], 'project' => $info['project']];
     }
     return $extensions;
 }
开发者ID:Briareos,项目名称:Oxygen,代码行数:19,代码来源:AttachStateListener.php

示例14: create

 /**
  * {@inheritdoc}
  */
 public function create($name, array $values = [])
 {
     $exists = (bool) $this->db->query("SELECT 1 FROM {umenu} WHERE name = ?", [$name])->fetchField();
     if ($exists) {
         throw new \InvalidArgumentException(sprintf("%s: cannot create menu, already exists", $name));
     }
     $values['name'] = $name;
     if (empty($values['title'])) {
         $values['title'] = $name;
     }
     unset($values['id']);
     $this->db->insert('umenu')->fields($values)->execute();
     $menu = $this->load($name);
     if ($this->dispatcher) {
         $this->dispatcher->dispatch('menu:create', new GenericEvent($menu));
     }
     return $menu;
 }
开发者ID:makinacorpus,项目名称:drupal-umenu,代码行数:21,代码来源:DrupalMenuStorage.php

示例15: garbageCollection

 /**
  * {@inheritdoc}
  */
 public function garbageCollection()
 {
     // Drop all messages for inactive subscriptions
     // FIXME: When volatile only
     $this->db->query("\n                    DELETE\n                    FROM {apb_queue}\n                    WHERE sub_id IN (\n                        SELECT id\n                        FROM {apb_sub}\n                        WHERE status = 0\n                    )\n                ");
     // Clean up expired messages
     if (false) {
         $this->db->query("DELETE FROM {apb_msg} WHERE created < :time", array(':time' => time() - $this->context->messageMaxLifetime));
     }
     // Limit queue size if configured for
     if (false) {
         $min = $this->db->query("\n                        SELECT msg_id\n                        FROM {apb_queue}\n                        ORDER BY msg_id DESC\n                        OFFSET :max LIMIT 1\n                    ", array(':max' => $this->context->queueGlobalLimit))->fetchField();
         if ($min) {
             // If the same message exists in many queues, we will never
             // reach the exact global limit: deleting all messages with
             // a lower id ensures that we may be close enought to this
             // limit
             $this->db->query("DELETE FROM {apb_queue} WHERE msg_id < :min", array(':min' => $min));
         }
     }
     // Clean up orphaned messages
     $this->db->query("\n                DELETE FROM {apb_msg}\n                WHERE id NOT IN (\n                    SELECT msg_id FROM {apb_queue}\n                )\n            ");
 }
开发者ID:makinacorpus,项目名称:drupal-apubsub,代码行数:26,代码来源:DrupalBackend.php


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