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


PHP OC_DB::getConnection方法代码示例

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


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

示例1: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->validateInput($input, $output);
     $this->readPassword($input, $output);
     $fromDB = \OC_DB::getConnection();
     $toDB = $this->getToDBConnection($input, $output);
     if ($input->getOption('clear-schema')) {
         $this->clearSchema($toDB, $input, $output);
     }
     $this->createSchema($toDB, $input, $output);
     $toTables = $this->getTables($toDB);
     $fromTables = $this->getTables($fromDB);
     // warn/fail if there are more tables in 'from' database
     $extraFromTables = array_diff($fromTables, $toTables);
     if (!empty($extraFromTables)) {
         $output->writeln('<comment>The following tables will not be converted:</comment>');
         $output->writeln($extraFromTables);
         if (!$input->getOption('all-apps')) {
             $output->writeln('<comment>Please note that tables belonging to available but currently not installed apps</comment>');
             $output->writeln('<comment>can be included by specifying the --all-apps option.</comment>');
         }
         /** @var $dialog \Symfony\Component\Console\Helper\DialogHelper */
         $dialog = $this->getHelperSet()->get('dialog');
         if (!$dialog->askConfirmation($output, '<question>Continue with the conversion (y/n)? [n] </question>', false)) {
             return;
         }
     }
     $intersectingTables = array_intersect($toTables, $fromTables);
     $this->convertDB($fromDB, $toDB, $intersectingTables, $input, $output);
 }
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:30,代码来源:converttype.php

示例2: __construct

 /**
  * @param \OC\Files\Storage\Storage|string $storage
  * @throws \RuntimeException
  */
 public function __construct($storage)
 {
     if ($storage instanceof \OC\Files\Storage\Storage) {
         $this->storageId = $storage->getId();
     } else {
         $this->storageId = $storage;
     }
     $this->storageId = self::adjustStorageId($this->storageId);
     $sql = 'SELECT `numeric_id` FROM `*PREFIX*storages` WHERE `id` = ?';
     $result = \OC_DB::executeAudited($sql, array($this->storageId));
     if ($row = $result->fetchRow()) {
         $this->numericId = $row['numeric_id'];
     } else {
         $connection = \OC_DB::getConnection();
         if ($connection->insertIfNotExist('*PREFIX*storages', ['id' => $this->storageId])) {
             $this->numericId = \OC_DB::insertid('*PREFIX*storages');
         } else {
             $result = \OC_DB::executeAudited($sql, array($this->storageId));
             if ($row = $result->fetchRow()) {
                 $this->numericId = $row['numeric_id'];
             } else {
                 throw new \RuntimeException('Storage could neither be inserted nor be selected from the database');
             }
         }
     }
 }
开发者ID:samj1912,项目名称:repo,代码行数:30,代码来源:storage.php

示例3: setUp

 public function setUp()
 {
     $this->config = \OC::$server->getConfig();
     $this->connection = \OC_DB::getConnection();
     $this->oldDataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data/');
     $this->repair = new \OC\Repair\RepairLegacyStorages($this->config, $this->connection);
 }
开发者ID:Combustible,项目名称:core,代码行数:7,代码来源:repairlegacystorage.php

示例4: runStep

 /**
  * Send an email to {$limit} users
  *
  * @param int $limit Number of users we want to send an email to
  * @return int Number of users we sent an email to
  */
 protected function runStep($limit)
 {
     // Get all users which should receive an email
     $affectedUsers = $this->mqHandler->getAffectedUsers($limit);
     if (empty($affectedUsers)) {
         // No users found to notify, mission abort
         return 0;
     }
     $preferences = new \OC\Preferences(\OC_DB::getConnection());
     $userLanguages = $preferences->getValueForUsers('core', 'lang', $affectedUsers);
     $userEmails = $preferences->getValueForUsers('settings', 'email', $affectedUsers);
     // Get all items for these users
     // We don't use time() but "time() - 1" here, so we don't run into
     // runtime issues and delete emails later, which were created in the
     // same second, but were not collected for the emails.
     $sendTime = time() - 1;
     $mailData = $this->mqHandler->getItemsForUsers($affectedUsers, $sendTime);
     // Send Email
     $default_lang = \OC_Config::getValue('default_language', 'en');
     foreach ($mailData as $user => $data) {
         if (!isset($userEmails[$user])) {
             // The user did not setup an email address
             // So we will not send an email :(
             continue;
         }
         $language = isset($userLanguages[$user]) ? $userLanguages[$user] : $default_lang;
         $this->mqHandler->sendEmailToUser($user, $userEmails[$user], $language, $data);
     }
     // Delete all entries we dealt with
     $this->mqHandler->deleteSentItems($affectedUsers, $sendTime);
     return sizeof($affectedUsers);
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:38,代码来源:emailnotification.php

示例5: setUp

 public function setUp()
 {
     $this->connection = \OC_DB::getConnection();
     if ($this->connection->getDriver() instanceof \Doctrine\DBAL\Driver\OCI8\Driver) {
         $this->markTestSkipped('DB migration tests arent supported on OCI');
     }
     $this->manager = new \OC\DB\MDB2SchemaManager($this->connection);
     $this->tableName = 'test_' . uniqid();
 }
开发者ID:olucao,项目名称:owncloud-core,代码行数:9,代码来源:migrator.php

示例6: setUp

 public function setUp()
 {
     $this->connection = \OC_DB::getConnection();
     if (!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\MySqlPlatform) {
         $this->markTestSkipped("Test only relevant on MySql");
     }
     $dbPrefix = \OC::$server->getConfig()->getSystemValue("dbtableprefix");
     $this->tableName = uniqid($dbPrefix . "_enum_bit_test");
     $this->connection->exec("CREATE TABLE {$this->tableName}(b BIT,  e ENUM('1','2','3','4'))");
 }
开发者ID:Combustible,项目名称:core,代码行数:10,代码来源:mysqlmigration.php

示例7: assertTableNotExist

 /**
  * @param string $table
  */
 public function assertTableNotExist($table)
 {
     $platform = \OC_DB::getConnection()->getDatabasePlatform();
     if ($platform instanceof \Doctrine\DBAL\Platforms\SqlitePlatform) {
         // sqlite removes the tables after closing the DB
         $this->assertTrue(true);
     } else {
         $this->assertFalse(OC_DB::tableExists($table), 'Table ' . $table . ' exists.');
     }
 }
开发者ID:0x17de,项目名称:core,代码行数:13,代码来源:dbschema.php

示例8: setUp

 public function setUp()
 {
     $this->connection = \OC_DB::getConnection();
     if (!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\SqlitePlatform) {
         $this->markTestSkipped("Test only relevant on Sqlite");
     }
     $dbPrefix = \OC::$server->getConfig()->getSystemValue("dbtableprefix");
     $this->tableName = uniqid($dbPrefix . "_enum_bit_test");
     $this->connection->exec("CREATE TABLE {$this->tableName}(t0 tinyint unsigned, t1 tinyint)");
 }
开发者ID:Combustible,项目名称:core,代码行数:10,代码来源:sqlitemigration.php

示例9: setUp

 public function setUp()
 {
     $this->connection = \OC_DB::getConnection();
     if (!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\MySqlPlatform) {
         $this->markTestSkipped("Test only relevant on MySql");
     }
     $dbPrefix = \OC::$server->getConfig()->getSystemValue("dbtableprefix");
     $this->tableName = uniqid($dbPrefix . "_innodb_test");
     $this->connection->exec("CREATE TABLE {$this->tableName}(id INT) ENGINE MyISAM");
     $this->repair = new \OC\Repair\InnoDB();
 }
开发者ID:olucao,项目名称:owncloud-core,代码行数:11,代码来源:repairinnodb.php

示例10: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $file = $input->getArgument('schema-xml');
     $schemaManager = new \OC\DB\MDB2SchemaManager(\OC_DB::getConnection());
     try {
         $result = $schemaManager->updateDbFromStructure($file, true);
         $output->writeln($result);
     } catch (\Exception $e) {
         $output->writeln('Failed to update database structure (' . $e . ')');
     }
 }
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:11,代码来源:generatechangescript.php

示例11: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->config = \OC::$server->getConfig();
     $this->connection = \OC_DB::getConnection();
     if ($this->connection->getDatabasePlatform() instanceof OraclePlatform) {
         $this->markTestSkipped('DB migration tests are not supported on OCI');
     }
     $this->manager = new \OC\DB\MDB2SchemaManager($this->connection);
     $this->tableName = strtolower($this->getUniqueID($this->config->getSystemValue('dbtableprefix', 'oc_') . 'test_'));
 }
开发者ID:evanjt,项目名称:core,代码行数:11,代码来源:migrator.php

示例12: getBeforeUpgradeRepairSteps

 /**
  * Returns the repair steps to be run before an
  * upgrade.
  *
  * @return array of RepairStep instances
  */
 public static function getBeforeUpgradeRepairSteps()
 {
     $steps = array(new \OC\Repair\InnoDB(), new \OC\Repair\Collation(\OC::$server->getConfig(), \OC_DB::getConnection()), new \OC\Repair\SearchLuceneTables(), new \OC\Repair\RepairConfig());
     //There is no need to delete all previews on every single update
     //only 7.0.0 thru 7.0.2 generated broken previews
     $currentVersion = \OC_Config::getValue('version');
     if (version_compare($currentVersion, '7.0.0.0', '>=') && version_compare($currentVersion, '7.0.3.4', '<=')) {
         $steps[] = new \OC\Repair\Preview();
     }
     return $steps;
 }
开发者ID:WYSAC,项目名称:oregon-owncloud,代码行数:17,代码来源:repair.php

示例13: setUp

 public function setUp()
 {
     $this->connection = \OC_DB::getConnection();
     $this->config = \OC::$server->getConfig();
     if (!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\MySqlPlatform) {
         $this->markTestSkipped("Test only relevant on MySql");
     }
     $dbPrefix = $this->config->getSystemValue("dbtableprefix");
     $this->tableName = uniqid($dbPrefix . "_collation_test");
     $this->connection->exec("CREATE TABLE {$this->tableName}(text VARCHAR(16)) COLLATE utf8_unicode_ci");
     $this->repair = new TestCollationRepair($this->config, $this->connection);
 }
开发者ID:olucao,项目名称:owncloud-core,代码行数:12,代码来源:repaircollation.php

示例14: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->config = \OC::$server->getConfig();
     $this->connection = \OC_DB::getConnection();
     $this->oldDataDir = $this->config->getSystemValue('datadirectory', \OC::$SERVERROOT . '/data/');
     $this->repair = new \OC\Repair\RepairLegacyStorages($this->config, $this->connection);
     $this->warnings = [];
     $this->repair->listen('\\OC\\Repair', 'warning', function ($description) {
         $this->warnings[] = $description;
     });
 }
开发者ID:adolfo2103,项目名称:hcloudfilem,代码行数:12,代码来源:repairlegacystorage.php

示例15: setUp

 public function setUp()
 {
     $this->connection = \OC_DB::getConnection();
     if ($this->connection->getDatabasePlatform() instanceof OraclePlatform) {
         $this->markTestSkipped('DB migration tests are not supported on OCI');
     }
     if ($this->connection->getDatabasePlatform() instanceof SQLServerPlatform) {
         $this->markTestSkipped('DB migration tests are not supported on MSSQL');
     }
     $this->manager = new \OC\DB\MDB2SchemaManager($this->connection);
     $this->tableName = 'test_' . uniqid();
 }
开发者ID:Romua1d,项目名称:core,代码行数:12,代码来源:migrator.php


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