Bump doctrine/dbal from 2.12.0 to 3.0.0
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>pull/24948/head
parent
84e6e9f7cf
commit
8b64e92b92
@ -1 +1 @@
|
||||
Subproject commit 86573beb84cf3b62b6d01ee377225df83b7d2453
|
||||
Subproject commit 09596e43fba86a3643879595a8fb6fece4af6a78
|
||||
@ -0,0 +1,172 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* @copyright 2020 Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||
*
|
||||
* @author 2020 Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace OC\DB;
|
||||
|
||||
use Doctrine\DBAL\Platforms\AbstractPlatform;
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use OCP\DB\IPreparedStatement;
|
||||
use OCP\DB\IResult;
|
||||
use OCP\DB\QueryBuilder\IQueryBuilder;
|
||||
use OCP\IDBConnection;
|
||||
|
||||
/**
|
||||
* Adapts the public API to our internal DBAL connection wrapper
|
||||
*/
|
||||
class ConnectionAdapter implements IDBConnection {
|
||||
|
||||
/** @var Connection */
|
||||
private $inner;
|
||||
|
||||
public function __construct(Connection $inner) {
|
||||
$this->inner = $inner;
|
||||
}
|
||||
|
||||
public function getQueryBuilder(): IQueryBuilder {
|
||||
return $this->inner->getQueryBuilder();
|
||||
}
|
||||
|
||||
public function prepare($sql, $limit = null, $offset = null): IPreparedStatement {
|
||||
return new PreparedStatement(
|
||||
$this->inner->prepare($sql, $limit, $offset)
|
||||
);
|
||||
}
|
||||
|
||||
public function executeQuery(string $sql, array $params = [], $types = []): IResult {
|
||||
return new ResultAdapter(
|
||||
$this->inner->executeQuery($sql, $params, $types)
|
||||
);
|
||||
}
|
||||
|
||||
public function executeUpdate(string $sql, array $params = [], array $types = []): int {
|
||||
return $this->inner->executeUpdate($sql, $params, $types);
|
||||
}
|
||||
|
||||
public function executeStatement($sql, array $params = [], array $types = []): int {
|
||||
return $this->inner->executeStatement($sql, $params, $types);
|
||||
}
|
||||
|
||||
public function lastInsertId(string $table): int {
|
||||
return (int) $this->inner->lastInsertId($table);
|
||||
}
|
||||
|
||||
public function insertIfNotExist(string $table, array $input, array $compare = null) {
|
||||
return $this->inner->insertIfNotExist($table, $input, $compare);
|
||||
}
|
||||
|
||||
public function insertIgnoreConflict(string $table, array $values): int {
|
||||
return $this->inner->insertIgnoreConflict($table, $values);
|
||||
}
|
||||
|
||||
public function setValues($table, array $keys, array $values, array $updatePreconditionValues = []): int {
|
||||
return $this->inner->setValues($table, $keys, $values, $updatePreconditionValues);
|
||||
}
|
||||
|
||||
public function lockTable($tableName): void {
|
||||
$this->inner->lockTable($tableName);
|
||||
}
|
||||
|
||||
public function unlockTable(): void {
|
||||
$this->inner->unlockTable();
|
||||
}
|
||||
|
||||
public function beginTransaction(): void {
|
||||
$this->inner->beginTransaction();
|
||||
}
|
||||
|
||||
public function inTransaction(): bool {
|
||||
return $this->inner->inTransaction();
|
||||
}
|
||||
|
||||
public function commit(): void {
|
||||
$this->inner->commit();
|
||||
}
|
||||
|
||||
public function rollBack(): void {
|
||||
$this->inner->rollBack();
|
||||
}
|
||||
|
||||
public function getError(): string {
|
||||
return $this->inner->getError();
|
||||
}
|
||||
|
||||
public function errorCode() {
|
||||
return $this->inner->errorCode();
|
||||
}
|
||||
|
||||
public function errorInfo() {
|
||||
return $this->inner->errorInfo();
|
||||
}
|
||||
|
||||
public function connect(): bool {
|
||||
return $this->inner->connect();
|
||||
}
|
||||
|
||||
public function close(): void {
|
||||
$this->inner->close();
|
||||
}
|
||||
|
||||
public function quote($input, $type = IQueryBuilder::PARAM_STR) {
|
||||
return $this->inner->quote($input, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo we are leaking a 3rdparty type here
|
||||
*/
|
||||
public function getDatabasePlatform(): AbstractPlatform {
|
||||
return $this->inner->getDatabasePlatform();
|
||||
}
|
||||
|
||||
public function dropTable(string $table): void {
|
||||
$this->inner->dropTable($table);
|
||||
}
|
||||
|
||||
public function tableExists(string $table): bool {
|
||||
return $this->inner->tableExists($table);
|
||||
}
|
||||
|
||||
public function escapeLikeParameter(string $param): string {
|
||||
return $this->inner->escapeLikeParameter($param);
|
||||
}
|
||||
|
||||
public function supports4ByteText(): bool {
|
||||
return $this->inner->supports4ByteText();
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo leaks a 3rdparty type
|
||||
*/
|
||||
public function createSchema(): Schema {
|
||||
return $this->inner->createSchema();
|
||||
}
|
||||
|
||||
public function migrateToSchema(Schema $toSchema): void {
|
||||
$this->inner->migrateToSchema($toSchema);
|
||||
}
|
||||
|
||||
public function getInner(): Connection {
|
||||
return $this->inner;
|
||||
}
|
||||
}
|
||||
@ -1,181 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
||||
*
|
||||
* @author Bart Visscher <bartv@thisnet.nl>
|
||||
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||
* @author Jörn Friedrich Dreyer <jfd@butonic.de>
|
||||
* @author Morris Jobke <hey@morrisjobke.de>
|
||||
* @author tbelau666 <thomas.belau@gmx.de>
|
||||
* @author Thomas Müller <thomas.mueller@tmit.eu>
|
||||
*
|
||||
* @license AGPL-3.0
|
||||
*
|
||||
* This code is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License, version 3,
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OC\DB;
|
||||
|
||||
use Doctrine\DBAL\Schema\Column;
|
||||
use Doctrine\DBAL\Schema\Index;
|
||||
|
||||
class MDB2SchemaWriter {
|
||||
|
||||
/**
|
||||
* @param string $file
|
||||
* @param \OC\DB\Connection $conn
|
||||
* @return bool
|
||||
*/
|
||||
public static function saveSchemaToFile($file, \OC\DB\Connection $conn) {
|
||||
$config = \OC::$server->getConfig();
|
||||
|
||||
$xml = new \SimpleXMLElement('<database/>');
|
||||
$xml->addChild('name', $config->getSystemValue('dbname', 'owncloud'));
|
||||
$xml->addChild('create', 'true');
|
||||
$xml->addChild('overwrite', 'false');
|
||||
if ($config->getSystemValue('dbtype', 'sqlite') === 'mysql' && $config->getSystemValue('mysql.utf8mb4', false)) {
|
||||
$xml->addChild('charset', 'utf8mb4');
|
||||
} else {
|
||||
$xml->addChild('charset', 'utf8');
|
||||
}
|
||||
|
||||
// FIX ME: bloody work around
|
||||
if ($config->getSystemValue('dbtype', 'sqlite') === 'oci') {
|
||||
$filterExpression = '/^"' . preg_quote($conn->getPrefix()) . '/';
|
||||
} else {
|
||||
$filterExpression = '/^' . preg_quote($conn->getPrefix()) . '/';
|
||||
}
|
||||
$conn->getConfiguration()->setFilterSchemaAssetsExpression($filterExpression);
|
||||
|
||||
foreach ($conn->getSchemaManager()->listTables() as $table) {
|
||||
self::saveTable($table, $xml->addChild('table'));
|
||||
}
|
||||
file_put_contents($file, $xml->asXML());
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Doctrine\DBAL\Schema\Table $table
|
||||
* @param \SimpleXMLElement $xml
|
||||
*/
|
||||
private static function saveTable($table, $xml) {
|
||||
$xml->addChild('name', $table->getName());
|
||||
$declaration = $xml->addChild('declaration');
|
||||
foreach ($table->getColumns() as $column) {
|
||||
self::saveColumn($column, $declaration->addChild('field'));
|
||||
}
|
||||
foreach ($table->getIndexes() as $index) {
|
||||
if ($index->getName() == 'PRIMARY') {
|
||||
$autoincrement = false;
|
||||
foreach ($index->getColumns() as $column) {
|
||||
if ($table->getColumn($column)->getAutoincrement()) {
|
||||
$autoincrement = true;
|
||||
}
|
||||
}
|
||||
if ($autoincrement) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
self::saveIndex($index, $declaration->addChild('index'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Column $column
|
||||
* @param \SimpleXMLElement $xml
|
||||
*/
|
||||
private static function saveColumn($column, $xml) {
|
||||
$xml->addChild('name', $column->getName());
|
||||
switch ($column->getType()) {
|
||||
case 'SmallInt':
|
||||
case 'Integer':
|
||||
case 'BigInt':
|
||||
$xml->addChild('type', 'integer');
|
||||
$default = $column->getDefault();
|
||||
if (is_null($default) && $column->getAutoincrement()) {
|
||||
$default = '0';
|
||||
}
|
||||
$xml->addChild('default', $default);
|
||||
$xml->addChild('notnull', self::toBool($column->getNotnull()));
|
||||
if ($column->getAutoincrement()) {
|
||||
$xml->addChild('autoincrement', '1');
|
||||
}
|
||||
if ($column->getUnsigned()) {
|
||||
$xml->addChild('unsigned', 'true');
|
||||
}
|
||||
$length = '4';
|
||||
if ($column->getType() == 'SmallInt') {
|
||||
$length = '2';
|
||||
} elseif ($column->getType() == 'BigInt') {
|
||||
$length = '8';
|
||||
}
|
||||
$xml->addChild('length', $length);
|
||||
break;
|
||||
case 'String':
|
||||
$xml->addChild('type', 'text');
|
||||
$default = trim($column->getDefault());
|
||||
if ($default === '') {
|
||||
$default = false;
|
||||
}
|
||||
$xml->addChild('default', $default);
|
||||
$xml->addChild('notnull', self::toBool($column->getNotnull()));
|
||||
$xml->addChild('length', $column->getLength());
|
||||
break;
|
||||
case 'Text':
|
||||
$xml->addChild('type', 'clob');
|
||||
$xml->addChild('notnull', self::toBool($column->getNotnull()));
|
||||
break;
|
||||
case 'Decimal':
|
||||
$xml->addChild('type', 'decimal');
|
||||
$xml->addChild('default', $column->getDefault());
|
||||
$xml->addChild('notnull', self::toBool($column->getNotnull()));
|
||||
$xml->addChild('length', '15');
|
||||
break;
|
||||
case 'Boolean':
|
||||
$xml->addChild('type', 'integer');
|
||||
$xml->addChild('default', $column->getDefault());
|
||||
$xml->addChild('notnull', self::toBool($column->getNotnull()));
|
||||
$xml->addChild('length', '1');
|
||||
break;
|
||||
case 'DateTime':
|
||||
$xml->addChild('type', 'timestamp');
|
||||
$xml->addChild('default', $column->getDefault());
|
||||
$xml->addChild('notnull', self::toBool($column->getNotnull()));
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Index $index
|
||||
* @param \SimpleXMLElement $xml
|
||||
*/
|
||||
private static function saveIndex($index, $xml) {
|
||||
$xml->addChild('name', $index->getName());
|
||||
if ($index->isPrimary()) {
|
||||
$xml->addChild('primary', 'true');
|
||||
} elseif ($index->isUnique()) {
|
||||
$xml->addChild('unique', 'true');
|
||||
}
|
||||
foreach ($index->getColumns() as $column) {
|
||||
$field = $xml->addChild('field');
|
||||
$field->addChild('name', $column);
|
||||
$field->addChild('sorting', 'ascending');
|
||||
}
|
||||
}
|
||||
|
||||
private static function toBool($bool) {
|
||||
return $bool ? 'true' : 'false';
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,101 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* @copyright 2021 Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||
*
|
||||
* @author 2021 Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace OC\DB;
|
||||
|
||||
use Doctrine\DBAL\Exception;
|
||||
use Doctrine\DBAL\ParameterType;
|
||||
use Doctrine\DBAL\Statement;
|
||||
use OCP\DB\IPreparedStatement;
|
||||
use OCP\DB\IResult;
|
||||
use PDO;
|
||||
|
||||
/**
|
||||
* Adapts our public API to what doctrine/dbal exposed with 2.6
|
||||
*
|
||||
* The old dbal statement had stateful methods e.g. to fetch data from an executed
|
||||
* prepared statement. To provide backwards compatibility to apps we need to make
|
||||
* this class stateful. As soon as those now deprecated exposed methods are gone,
|
||||
* we can limit the API of this adapter to the methods that map to the direct dbal
|
||||
* methods without much magic.
|
||||
*/
|
||||
class PreparedStatement implements IPreparedStatement {
|
||||
|
||||
/** @var Statement */
|
||||
private $statement;
|
||||
|
||||
/** @var IResult|null */
|
||||
private $result;
|
||||
|
||||
public function __construct(Statement $statement) {
|
||||
$this->statement = $statement;
|
||||
}
|
||||
|
||||
public function closeCursor(): bool {
|
||||
$this->getResult()->closeCursor();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function fetch(int $fetchMode = PDO::FETCH_ASSOC) {
|
||||
return $this->getResult()->fetch($fetchMode);
|
||||
}
|
||||
|
||||
public function fetchAll(int $fetchMode = PDO::FETCH_ASSOC): array {
|
||||
return $this->getResult()->fetchAll($fetchMode);
|
||||
}
|
||||
|
||||
public function fetchColumn() {
|
||||
return $this->getResult()->fetchOne();
|
||||
}
|
||||
|
||||
public function fetchOne() {
|
||||
return $this->getResult()->fetchOne();
|
||||
}
|
||||
|
||||
public function bindValue($param, $value, $type = ParameterType::STRING): bool {
|
||||
return $this->statement->bindValue($param, $value, $type);
|
||||
}
|
||||
|
||||
public function bindParam($param, &$variable, $type = ParameterType::STRING, $length = null): bool {
|
||||
return $this->statement->bindParam($param, $variable, $type, $length);
|
||||
}
|
||||
|
||||
public function execute($params = null): IResult {
|
||||
return ($this->result = new ResultAdapter($this->statement->execute($params)));
|
||||
}
|
||||
|
||||
public function rowCount(): int {
|
||||
return $this->getResult()->rowCount();
|
||||
}
|
||||
|
||||
private function getResult(): IResult {
|
||||
if ($this->result !== null) {
|
||||
return $this->result;
|
||||
}
|
||||
|
||||
throw new Exception("You have to execute the prepared statement before accessing the results");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/*
|
||||
* @copyright 2021 Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||
*
|
||||
* @author 2021 Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OC\DB;
|
||||
|
||||
use Doctrine\DBAL\Result;
|
||||
use OCP\DB\IResult;
|
||||
use PDO;
|
||||
|
||||
/**
|
||||
* Adapts DBAL 2.6 API for DBAL 3.x for backwards compatibility of a leaked type
|
||||
*/
|
||||
class ResultAdapter implements IResult {
|
||||
|
||||
/** @var Result */
|
||||
private $inner;
|
||||
|
||||
public function __construct(Result $inner) {
|
||||
$this->inner = $inner;
|
||||
}
|
||||
|
||||
public function closeCursor(): bool {
|
||||
$this->inner->free();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function fetch(int $fetchMode = PDO::FETCH_ASSOC) {
|
||||
return $this->inner->fetch($fetchMode);
|
||||
}
|
||||
|
||||
public function fetchAll(int $fetchMode = PDO::FETCH_ASSOC): array {
|
||||
if ($fetchMode !== PDO::FETCH_ASSOC && $fetchMode !== PDO::FETCH_NUM && $fetchMode !== PDO::FETCH_COLUMN) {
|
||||
throw new \Exception('Fetch mode needs to be assoc, num or column.');
|
||||
}
|
||||
return $this->inner->fetchAll($fetchMode);
|
||||
}
|
||||
|
||||
public function fetchColumn($columnIndex = 0) {
|
||||
return $this->inner->fetchOne();
|
||||
}
|
||||
|
||||
public function fetchOne() {
|
||||
return $this->inner->fetchOne();
|
||||
}
|
||||
|
||||
public function rowCount(): int {
|
||||
return $this->inner->rowCount();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,127 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* @copyright 2021 Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||
*
|
||||
* @author 2021 Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace OCP\DB;
|
||||
|
||||
use Doctrine\DBAL\Exception;
|
||||
use Doctrine\DBAL\ParameterType;
|
||||
use PDO;
|
||||
|
||||
/**
|
||||
* @since 21.0.0
|
||||
*/
|
||||
interface IPreparedStatement {
|
||||
|
||||
/**
|
||||
* @return true
|
||||
*
|
||||
* @since 21.0.0
|
||||
* @deprecated 21.0.0 use \OCP\DB\IResult::closeCursor on the \OCP\DB\IResult returned by \OCP\IDBConnection::prepare
|
||||
*/
|
||||
public function closeCursor(): bool;
|
||||
|
||||
/**
|
||||
* @param int $fetchMode
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @since 21.0.0
|
||||
* @deprecated 21.0.0 use \OCP\DB\IResult::fetch on the \OCP\DB\IResult returned by \OCP\IDBConnection::prepare
|
||||
*/
|
||||
public function fetch(int $fetchMode = PDO::FETCH_ASSOC);
|
||||
|
||||
/**
|
||||
* @param int $fetchMode
|
||||
*
|
||||
* @return mixed[]
|
||||
*
|
||||
* @since 21.0.0
|
||||
* @deprecated 21.0.0 use \OCP\DB\IResult::fetchAll on the \OCP\DB\IResult returned by \OCP\IDBConnection::prepare
|
||||
*/
|
||||
public function fetchAll(int $fetchMode = PDO::FETCH_ASSOC);
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*
|
||||
* @since 21.0.0
|
||||
* @deprecated 21.0.0 use \OCP\DB\IResult::fetchColumn on the \OCP\DB\IResult returned by \OCP\IDBConnection::prepare
|
||||
*/
|
||||
public function fetchColumn();
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*
|
||||
* @since 21.0.0
|
||||
* @deprecated 21.0.0 use \OCP\DB\IResult::fetchOne on the \OCP\DB\IResult returned by \OCP\IDBConnection::prepare
|
||||
*/
|
||||
public function fetchOne();
|
||||
|
||||
/**
|
||||
* @param int|string $param
|
||||
* @param mixed $value
|
||||
* @param int $type
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws Exception
|
||||
*
|
||||
* @since 21.0.0
|
||||
*/
|
||||
public function bindValue($param, $value, $type = ParameterType::STRING): bool;
|
||||
|
||||
/**
|
||||
* @param int|string $param
|
||||
* @param mixed $variable
|
||||
* @param int $type
|
||||
* @param int|null $length
|
||||
*
|
||||
* @return bool
|
||||
*
|
||||
* @throws Exception
|
||||
*
|
||||
* @since 21.0.0
|
||||
*/
|
||||
public function bindParam($param, &$variable, $type = ParameterType::STRING, $length = null): bool;
|
||||
|
||||
/**
|
||||
* @param mixed[]|null $params
|
||||
*
|
||||
* @return IResult
|
||||
*
|
||||
* @since 21.0.0
|
||||
* @throws Exception
|
||||
*/
|
||||
public function execute($params = null): IResult;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*
|
||||
* @since 21.0.0
|
||||
*
|
||||
* @throws Exception
|
||||
* @deprecated 21.0.0 use \OCP\DB\IResult::rowCount on the \OCP\DB\IResult returned by \OCP\IDBConnection::prepare
|
||||
*/
|
||||
public function rowCount(): int;
|
||||
}
|
||||
@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* @copyright 2021 Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||
*
|
||||
* @author 2021 Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace OCP\DB;
|
||||
|
||||
use PDO;
|
||||
|
||||
/**
|
||||
* @since 21.0.0
|
||||
*/
|
||||
interface IResult {
|
||||
|
||||
/**
|
||||
* @return true
|
||||
*
|
||||
* @since 21.0.0
|
||||
*/
|
||||
public function closeCursor(): bool;
|
||||
|
||||
/**
|
||||
* @param int $fetchMode
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @since 21.0.0
|
||||
*/
|
||||
public function fetch(int $fetchMode = PDO::FETCH_ASSOC);
|
||||
|
||||
/**
|
||||
* @param int $fetchMode (one of PDO::FETCH_ASSOC, PDO::FETCH_NUM or PDO::FETCH_COLUMN (2, 3 or 7)
|
||||
*
|
||||
* @return mixed[]
|
||||
*
|
||||
* @since 21.0.0
|
||||
*/
|
||||
public function fetchAll(int $fetchMode = PDO::FETCH_ASSOC): array;
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*
|
||||
* @since 21.0.0
|
||||
* @deprecated 21.0.0 use \OCP\DB\IResult::fetchOne
|
||||
*/
|
||||
public function fetchColumn();
|
||||
|
||||
/**
|
||||
* @param int $columnIndex
|
||||
*
|
||||
* @return false|mixed
|
||||
*
|
||||
* @since 21.0.0
|
||||
*/
|
||||
public function fetchOne();
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*
|
||||
* @since 21.0.0
|
||||
*/
|
||||
public function rowCount(): int;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue