|
|
|
|
@ -9,7 +9,6 @@ namespace OC\DB\QueryBuilder;
|
|
|
|
|
|
|
|
|
|
use Doctrine\DBAL\Query\QueryException;
|
|
|
|
|
use OC\DB\ConnectionAdapter;
|
|
|
|
|
use OC\DB\Exceptions\DbalException;
|
|
|
|
|
use OC\DB\QueryBuilder\ExpressionBuilder\MySqlExpressionBuilder;
|
|
|
|
|
use OC\DB\QueryBuilder\ExpressionBuilder\OCIExpressionBuilder;
|
|
|
|
|
use OC\DB\QueryBuilder\ExpressionBuilder\PgSqlExpressionBuilder;
|
|
|
|
|
@ -254,30 +253,6 @@ class QueryBuilder implements IQueryBuilder {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Executes this query using the bound parameters and their types.
|
|
|
|
|
*
|
|
|
|
|
* Uses {@see Connection::executeQuery} for select statements and {@see Connection::executeUpdate}
|
|
|
|
|
* for insert, update and delete statements.
|
|
|
|
|
*
|
|
|
|
|
* @return IResult|int
|
|
|
|
|
*/
|
|
|
|
|
public function execute(?IDBConnection $connection = null) {
|
|
|
|
|
try {
|
|
|
|
|
if ($this->getType() === \Doctrine\DBAL\Query\QueryBuilder::SELECT) {
|
|
|
|
|
return $this->executeQuery($connection);
|
|
|
|
|
} else {
|
|
|
|
|
return $this->executeStatement($connection);
|
|
|
|
|
}
|
|
|
|
|
} catch (DBALException $e) {
|
|
|
|
|
// `IQueryBuilder->execute` never wrapped the exception, but `executeQuery` and `executeStatement` do
|
|
|
|
|
/** @var \Doctrine\DBAL\Exception $previous */
|
|
|
|
|
$previous = $e->getPrevious();
|
|
|
|
|
|
|
|
|
|
throw $previous;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function executeQuery(?IDBConnection $connection = null): IResult {
|
|
|
|
|
if ($this->getType() !== \Doctrine\DBAL\Query\QueryBuilder::SELECT) {
|
|
|
|
|
throw new \RuntimeException('Invalid query type, expected SELECT query');
|
|
|
|
|
|