/** * @param string $table */ public function assertTableNotExist($table) { if ($this->connection->getDatabasePlatform() instanceof SqlitePlatform) { // sqlite removes the tables after closing the DB $this->assertTrue(true); } else { $this->assertFalse($this->connection->tableExists($table), 'Table ' . $table . ' doesnt exists.'); } }
/** * Make sure all user roots have permissions 23 (all but share) */ protected function fixUserRootPermissions() { $qb = $this->connection->getQueryBuilder(); $qb2 = $this->connection->getQueryBuilder(); $qb->select('numeric_id')->from('storages')->where($qb->expr()->like('id', $qb2->createParameter('like'))); if ($this->connection->getDatabasePlatform() instanceof OraclePlatform) { // '' is null on oracle $path = $qb2->expr()->isNull('path'); } else { $path = $qb2->expr()->eq('path', $qb2->createNamedParameter('')); } $qb2->update('filecache')->set('permissions', $qb2->createNamedParameter(23))->where($path)->andWhere($qb2->expr()->in('storage', $qb2->createFunction($qb->getSQL())))->andWhere($qb2->expr()->neq('permissions', $qb2->createNamedParameter(23)))->setParameter('like', 'home::%'); $qb2->execute(); }
/** * Gets an ExpressionBuilder used for object-oriented construction of query expressions. * This producer method is intended for convenient inline usage. Example: * * <code> * $qb = $conn->getQueryBuilder() * ->select('u') * ->from('users', 'u') * ->where($qb->expr()->eq('u.id', 1)); * </code> * * For more complex expression construction, consider storing the expression * builder object in a local variable. * * @return \OCP\DB\QueryBuilder\IExpressionBuilder */ public function expr() { if ($this->connection instanceof OracleConnection) { return new OCIExpressionBuilder($this->connection); } else { if ($this->connection->getDatabasePlatform() instanceof PostgreSqlPlatform) { return new PgSqlExpressionBuilder($this->connection); } else { return new ExpressionBuilder($this->connection); } } }
/** * Truncate's the mapping table * @return bool */ public function clear() { $sql = $this->dbc->getDatabasePlatform()->getTruncateTableSQL('`' . $this->getTableName() . '`'); return $this->dbc->prepare($sql)->execute(); }
/** * Gets the DatabasePlatform instance that provides all the metadata about * the platform this driver connects to. * * @return \Doctrine\DBAL\Platforms\AbstractPlatform The database platform. */ public function getDatabasePlatform() { return $this->connection->getDatabasePlatform(); }