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


PHP Connection::prepare方法代碼示例

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


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

示例1: __construct

 /**
  * @param \OCP\IConfig $config
  * @param \OC\DB\Connection $connection
  */
 public function __construct($config, $connection)
 {
     $this->connection = $connection;
     $this->config = $config;
     $this->findStorageInCacheStatement = $this->connection->prepare('SELECT DISTINCT `storage` FROM `*PREFIX*filecache`' . ' WHERE `storage` in (?, ?)');
     $this->renameStorageStatement = $this->connection->prepare('UPDATE `*PREFIX*storages`' . ' SET `id` = ?' . ' WHERE `id` = ?');
 }
開發者ID:kebenxiaoming,項目名稱:owncloudRedis,代碼行數:11,代碼來源:repairlegacystorages.php

示例2: run

 /**
  * Fix mime types
  */
 public function run()
 {
     if (!$this->connection->getDatabasePlatform() instanceof MySqlPlatform) {
         $this->emit('\\OC\\Repair', 'info', array('Not a mysql database -> nothing to no'));
         return;
     }
     $tables = $this->getAllNonUTF8BinTables($this->connection);
     foreach ($tables as $table) {
         $query = $this->connection->prepare('ALTER TABLE `' . $table . '` CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;');
         $query->execute();
     }
 }
開發者ID:spielhoelle,項目名稱:owncloud,代碼行數:15,代碼來源:collation.php

示例3: run

 /**
  * Fix mime types
  */
 public function run(IOutput $output)
 {
     if (!$this->connection->getDatabasePlatform() instanceof MySqlPlatform) {
         $output->info('Not a mysql database -> nothing to no');
         return;
     }
     $tables = $this->getAllNonUTF8BinTables($this->connection);
     foreach ($tables as $table) {
         $output->info("Change collation for {$table} ...");
         $query = $this->connection->prepare('ALTER TABLE `' . $table . '` CONVERT TO CHARACTER SET utf8 COLLATE utf8_bin;');
         $query->execute();
     }
 }
開發者ID:GitHubUser4234,項目名稱:core,代碼行數:16,代碼來源:Collation.php

示例4: getUsersForValue

 /**
  * Gets the users for a preference
  * @param string $app
  * @param string $key
  * @param string $value
  * @param int|null $limit
  * @param int|null $offset
  * @return array
  */
 public function getUsersForValue($app, $key, $value, $limit = null, $offset = null)
 {
     $users = array();
     $query = 'SELECT `userid` ' . ' FROM `*PREFIX*preferences` ' . ' WHERE `appid` = ? AND `configkey` = ? AND ';
     if (\OC_Config::getValue('dbtype', 'sqlite') === 'oci') {
         //FIXME oracle hack: need to explicitly cast CLOB to CHAR for comparison
         $query .= ' to_char(`configvalue`)= ?';
     } else {
         $query .= ' `configvalue` = ?';
     }
     $stmt = $this->conn->prepare($query, $limit, $offset);
     $stmt->execute(array($app, $key, $value));
     while ($row = $stmt->fetch()) {
         $users[] = $row['userid'];
     }
     return $users;
 }
開發者ID:droiter,項目名稱:openwrt-on-android,代碼行數:26,代碼來源:preferences.php

示例5: prepare

 /**
  * Prepare a SQL query
  * @param string $query Query string
  * @param int $limit
  * @param int $offset
  * @param bool $isManipulation
  * @throws DatabaseException
  * @return OC_DB_StatementWrapper prepared SQL query
  *
  * SQL query via Doctrine prepare(), needs to be execute()'d!
  */
 public static function prepare($query, $limit = null, $offset = null, $isManipulation = null)
 {
     self::connect();
     if ($isManipulation === null) {
         //try to guess, so we return the number of rows on manipulations
         $isManipulation = self::isManipulation($query);
     }
     // return the result
     try {
         $result = self::$connection->prepare($query, $limit, $offset);
     } catch (\Doctrine\DBAL\DBALException $e) {
         throw new \DatabaseException($e->getMessage(), $query);
     }
     // differentiate between query and manipulation
     $result = new OC_DB_StatementWrapper($result, $isManipulation);
     return $result;
 }
開發者ID:Combustible,項目名稱:core,代碼行數:28,代碼來源:db.php


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