/**
  * @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` = ?');
 }
示例#2
0
 /**
  * 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();
     }
 }
示例#3
0
 /**
  * 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();
     }
 }
 /**
  * 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;
 }
示例#5
0
文件: db.php 项目: Combustible/core
 /**
  * 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;
 }