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