$this->validateInput($input, $output);
$this->readPassword($input, $output);
- $fromDB = \OC_DB::getConnection();
+ $fromDB = \OC::$server->getDatabaseConnection();
$toDB = $this->getToDBConnection($input, $output);
if ($input->getOption('clear-schema')) {
$file = $input->getArgument('schema-xml');
- $schemaManager = new \OC\DB\MDB2SchemaManager(\OC_DB::getConnection());
+ $schemaManager = new \OC\DB\MDB2SchemaManager(\OC::$server->getDatabaseConnection());
try {
$result = $schemaManager->updateDbFromStructure($file, true);
*/
class OC_DB {
- /**
- * @return \OCP\IDBConnection
- */
- static public function getConnection() {
- return \OC::$server->getDatabaseConnection();
- }
-
/**
* get MDB2 schema manager
*
if ($row = self::getStorageById($this->storageId)) {
$this->numericId = $row['numeric_id'];
} else {
- $connection = \OC_DB::getConnection();
+ $connection = \OC::$server->getDatabaseConnection();
$available = $isAvailable ? 1 : 0;
if ($connection->insertIfNotExist('*PREFIX*storages', ['id' => $this->storageId, 'available' => $available])) {
- $this->numericId = \OC::$server->getDatabaseConnection()->lastInsertId('*PREFIX*storages');
+ $this->numericId = $connection->lastInsertId('*PREFIX*storages');
} else {
if ($row = self::getStorageById($this->storageId)) {
$this->numericId = $row['numeric_id'];
* @return array of RepairStep instances
*/
public static function getBeforeUpgradeRepairSteps() {
+ $connection = \OC::$server->getDatabaseConnection();
$steps = [
new InnoDB(),
- new Collation(\OC::$server->getConfig(), \OC_DB::getConnection()),
- new SqliteAutoincrement(\OC_DB::getConnection()),
+ new Collation(\OC::$server->getConfig(), $connection),
+ new SqliteAutoincrement($connection),
new SearchLuceneTables(),
];
* Fix mime types
*/
public function run() {
- $connection = \OC_DB::getConnection();
+ $connection = \OC::$server->getDatabaseConnection();
if (!$connection->getDatabasePlatform() instanceof MySqlPlatform) {
$this->emit('\OC\Repair', 'info', array('Not a mysql database -> nothing to do'));
return;
* search_lucene will then reindex the fileids without a status when the next indexing job is executed
*/
public function run() {
- if (\OC_DB::tableExists('lucene_status')) {
+ $connection = \OC::$server->getDatabaseConnection();
+ if ($connection->tableExists('lucene_status')) {
$this->emit('\OC\Repair', 'info', array('removing duplicate entries from lucene_status'));
- $connection = \OC_DB::getConnection();
$query = $connection->prepare('
DELETE FROM `*PREFIX*lucene_status`
WHERE `fileid` IN (
$this->registerService('SystemConfig', function ($c) use ($config) {
return new \OC\SystemConfig($config);
});
- $this->registerService('AppConfig', function ($c) {
- return new \OC\AppConfig(\OC_DB::getConnection());
+ $this->registerService('AppConfig', function (Server $c) {
+ return new \OC\AppConfig($c->getDatabaseConnection());
});
$this->registerService('L10NFactory', function ($c) {
return new \OC\L10N\Factory();
// TODO: inject connection, hopefully one day in the future when this
// class isn't static anymore...
- $conn = \OC_DB::getConnection();
+ $conn = \OC::$server->getDatabaseConnection();
$result = $conn->executeQuery(
'SELECT ' . $select . ' FROM `*PREFIX*share` ' . $where,
$arguments,
$entries = array();
try {
- $conn = \OC_DB::getConnection();
+ $conn = \OC::$server->getDatabaseConnection();
$chunks = array_chunk($objIds, 900, false);
foreach ($chunks as $chunk) {
$result = $conn->executeQuery(
$appConfig = $this->getMock(
'\OC\AppConfig',
array('getValues'),
- array(\OC_DB::getConnection()),
+ array(\OC::$server->getDatabaseConnection()),
'',
false
);
* Restore the original app config service.
*/
private function restoreAppConfig() {
- \OC::$server->registerService('AppConfig', function ($c) {
- return new \OC\AppConfig(\OC_DB::getConnection());
+ \OC::$server->registerService('AppConfig', function (\OC\Server $c) {
+ return new \OC\AppConfig($c->getDatabaseConnection());
});
\OC::$server->registerService('AppManager', function (\OC\Server $c) {
return new \OC\App\AppManager($c->getUserSession(), $c->getAppConfig(), $c->getGroupManager(), $c->getMemCacheFactory());
public function testAutoIncrement() {
- $connection = \OC_DB::getConnection();
+ $connection = \OC::$server->getDatabaseConnection();
if ($connection->getDatabasePlatform() instanceof OraclePlatform) {
$this->markTestSkipped('Adding auto increment columns in Oracle is not supported.');
}
parent::setUp();
$this->config = \OC::$server->getConfig();
- $this->connection = \OC_DB::getConnection();
+ $this->connection = \OC::$server->getDatabaseConnection();
if ($this->connection->getDatabasePlatform() instanceof OraclePlatform) {
$this->markTestSkipped('DB migration tests are not supported on OCI');
}
protected function setUp() {
parent::setUp();
- $this->connection = \OC_DB::getConnection();
+ $this->connection = \OC::$server->getDatabaseConnection();
if (!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\MySqlPlatform) {
$this->markTestSkipped("Test only relevant on MySql");
}
protected function setUp() {
parent::setUp();
- $this->connection = \OC_DB::getConnection();
+ $this->connection = \OC::$server->getDatabaseConnection();
if (!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\SqlitePlatform) {
$this->markTestSkipped("Test only relevant on Sqlite");
}
* @medium
*/
public function testSchema() {
- $platform = \OC_DB::getConnection()->getDatabasePlatform();
+ $platform = \OC::$server->getDatabaseConnection()->getDatabasePlatform();
$this->doTestSchemaCreating();
$this->doTestSchemaChanging();
$this->doTestSchemaDumping();
* @param string $table
*/
public function assertTableNotExist($table) {
- $platform = \OC_DB::getConnection()->getDatabasePlatform();
+ $platform = \OC::$server->getDatabaseConnection()->getDatabasePlatform();
if ($platform instanceof \Doctrine\DBAL\Platforms\SqlitePlatform) {
// sqlite removes the tables after closing the DB
$this->assertTrue(true);
protected function setUp() {
parent::setUp();
- $this->connection = \OC_DB::getConnection();
+ $this->connection = \OC::$server->getDatabaseConnection();
$this->config = \OC::$server->getConfig();
if (!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\MySqlPlatform) {
$this->markTestSkipped("Test only relevant on MySql");
protected function setUp() {
parent::setUp();
- $this->connection = \OC_DB::getConnection();
+ $this->connection = \OC::$server->getDatabaseConnection();
if (!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\MySqlPlatform) {
$this->markTestSkipped("Test only relevant on MySql");
}
protected function setUp() {
parent::setUp();
- $this->connection = \OC_DB::getConnection();
+ $this->connection = \OC::$server->getDatabaseConnection();
$this->config = \OC::$server->getConfig();
if (!$this->connection->getDatabasePlatform() instanceof \Doctrine\DBAL\Platforms\SqlitePlatform) {
$this->markTestSkipped("Test only relevant on Sqlite");
}
protected function tearDown() {
- $conn = \OC_DB::getConnection();
+ $conn = \OC::$server->getDatabaseConnection();
$conn->executeQuery('DELETE FROM `*PREFIX*vcategory_to_object`');
$conn->executeQuery('DELETE FROM `*PREFIX*vcategory`');
$tagId = $tagData[0]['id'];
$tagType = $tagData[0]['type'];
- $conn = \OC_DB::getConnection();
+ $conn = \OC::$server->getDatabaseConnection();
$statement = $conn->prepare(
'INSERT INTO `*PREFIX*vcategory_to_object` ' .
'(`objid`, `categoryid`, `type`) VALUES ' .