Subiendo proyecto completo sin restricciones de git ignore
This commit is contained in:
107
vendor/doctrine/dbal/src/Driver/SQLite3/Connection.php
vendored
Normal file
107
vendor/doctrine/dbal/src/Driver/SQLite3/Connection.php
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\DBAL\Driver\SQLite3;
|
||||
|
||||
use Doctrine\DBAL\Driver\ServerInfoAwareConnection;
|
||||
use Doctrine\DBAL\ParameterType;
|
||||
use SQLite3;
|
||||
|
||||
use function assert;
|
||||
use function sprintf;
|
||||
|
||||
final class Connection implements ServerInfoAwareConnection
|
||||
{
|
||||
private SQLite3 $connection;
|
||||
|
||||
/** @internal The connection can be only instantiated by its driver. */
|
||||
public function __construct(SQLite3 $connection)
|
||||
{
|
||||
$this->connection = $connection;
|
||||
}
|
||||
|
||||
public function prepare(string $sql): Statement
|
||||
{
|
||||
try {
|
||||
$statement = $this->connection->prepare($sql);
|
||||
} catch (\Exception $e) {
|
||||
throw Exception::new($e);
|
||||
}
|
||||
|
||||
assert($statement !== false);
|
||||
|
||||
return new Statement($this->connection, $statement);
|
||||
}
|
||||
|
||||
public function query(string $sql): Result
|
||||
{
|
||||
try {
|
||||
$result = $this->connection->query($sql);
|
||||
} catch (\Exception $e) {
|
||||
throw Exception::new($e);
|
||||
}
|
||||
|
||||
assert($result !== false);
|
||||
|
||||
return new Result($result, $this->connection->changes());
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
public function quote($value, $type = ParameterType::STRING): string
|
||||
{
|
||||
return sprintf('\'%s\'', SQLite3::escapeString($value));
|
||||
}
|
||||
|
||||
public function exec(string $sql): int
|
||||
{
|
||||
try {
|
||||
$this->connection->exec($sql);
|
||||
} catch (\Exception $e) {
|
||||
throw Exception::new($e);
|
||||
}
|
||||
|
||||
return $this->connection->changes();
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
public function lastInsertId($name = null): int
|
||||
{
|
||||
return $this->connection->lastInsertRowID();
|
||||
}
|
||||
|
||||
public function beginTransaction(): bool
|
||||
{
|
||||
try {
|
||||
return $this->connection->exec('BEGIN');
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function commit(): bool
|
||||
{
|
||||
try {
|
||||
return $this->connection->exec('COMMIT');
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function rollBack(): bool
|
||||
{
|
||||
try {
|
||||
return $this->connection->exec('ROLLBACK');
|
||||
} catch (\Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function getNativeConnection(): SQLite3
|
||||
{
|
||||
return $this->connection;
|
||||
}
|
||||
|
||||
public function getServerVersion(): string
|
||||
{
|
||||
return SQLite3::version()['versionString'];
|
||||
}
|
||||
}
|
||||
49
vendor/doctrine/dbal/src/Driver/SQLite3/Driver.php
vendored
Normal file
49
vendor/doctrine/dbal/src/Driver/SQLite3/Driver.php
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\DBAL\Driver\SQLite3;
|
||||
|
||||
use Doctrine\DBAL\Driver\AbstractSQLiteDriver;
|
||||
use Doctrine\DBAL\Driver\API\SQLite\UserDefinedFunctions;
|
||||
use SensitiveParameter;
|
||||
use SQLite3;
|
||||
|
||||
final class Driver extends AbstractSQLiteDriver
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function connect(
|
||||
#[SensitiveParameter]
|
||||
array $params
|
||||
): Connection {
|
||||
$isMemory = (bool) ($params['memory'] ?? false);
|
||||
|
||||
if (isset($params['path'])) {
|
||||
if ($isMemory) {
|
||||
throw new Exception(
|
||||
'Invalid connection settings: specifying both parameters "path" and "memory" is ambiguous.',
|
||||
);
|
||||
}
|
||||
|
||||
$filename = $params['path'];
|
||||
} elseif ($isMemory) {
|
||||
$filename = ':memory:';
|
||||
} else {
|
||||
throw new Exception(
|
||||
'Invalid connection settings: specify either the "path" or the "memory" parameter for SQLite3.',
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
$connection = new SQLite3($filename);
|
||||
} catch (\Exception $e) {
|
||||
throw Exception::new($e);
|
||||
}
|
||||
|
||||
$connection->enableExceptions(true);
|
||||
|
||||
UserDefinedFunctions::register([$connection, 'createFunction']);
|
||||
|
||||
return new Connection($connection);
|
||||
}
|
||||
}
|
||||
18
vendor/doctrine/dbal/src/Driver/SQLite3/Exception.php
vendored
Normal file
18
vendor/doctrine/dbal/src/Driver/SQLite3/Exception.php
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\DBAL\Driver\SQLite3;
|
||||
|
||||
use Doctrine\DBAL\Driver\AbstractException;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*
|
||||
* @psalm-immutable
|
||||
*/
|
||||
final class Exception extends AbstractException
|
||||
{
|
||||
public static function new(\Exception $exception): self
|
||||
{
|
||||
return new self($exception->getMessage(), null, (int) $exception->getCode(), $exception);
|
||||
}
|
||||
}
|
||||
91
vendor/doctrine/dbal/src/Driver/SQLite3/Result.php
vendored
Normal file
91
vendor/doctrine/dbal/src/Driver/SQLite3/Result.php
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\DBAL\Driver\SQLite3;
|
||||
|
||||
use Doctrine\DBAL\Driver\FetchUtils;
|
||||
use Doctrine\DBAL\Driver\Result as ResultInterface;
|
||||
use SQLite3Result;
|
||||
|
||||
use const SQLITE3_ASSOC;
|
||||
use const SQLITE3_NUM;
|
||||
|
||||
final class Result implements ResultInterface
|
||||
{
|
||||
private ?SQLite3Result $result;
|
||||
private int $changes;
|
||||
|
||||
/** @internal The result can be only instantiated by its driver connection or statement. */
|
||||
public function __construct(SQLite3Result $result, int $changes)
|
||||
{
|
||||
$this->result = $result;
|
||||
$this->changes = $changes;
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
public function fetchNumeric()
|
||||
{
|
||||
if ($this->result === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->result->fetchArray(SQLITE3_NUM);
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
public function fetchAssociative()
|
||||
{
|
||||
if ($this->result === null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->result->fetchArray(SQLITE3_ASSOC);
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
public function fetchOne()
|
||||
{
|
||||
return FetchUtils::fetchOne($this);
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
public function fetchAllNumeric(): array
|
||||
{
|
||||
return FetchUtils::fetchAllNumeric($this);
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
public function fetchAllAssociative(): array
|
||||
{
|
||||
return FetchUtils::fetchAllAssociative($this);
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
public function fetchFirstColumn(): array
|
||||
{
|
||||
return FetchUtils::fetchFirstColumn($this);
|
||||
}
|
||||
|
||||
public function rowCount(): int
|
||||
{
|
||||
return $this->changes;
|
||||
}
|
||||
|
||||
public function columnCount(): int
|
||||
{
|
||||
if ($this->result === null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return $this->result->numColumns();
|
||||
}
|
||||
|
||||
public function free(): void
|
||||
{
|
||||
if ($this->result === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->result->finalize();
|
||||
$this->result = null;
|
||||
}
|
||||
}
|
||||
119
vendor/doctrine/dbal/src/Driver/SQLite3/Statement.php
vendored
Normal file
119
vendor/doctrine/dbal/src/Driver/SQLite3/Statement.php
vendored
Normal file
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
|
||||
namespace Doctrine\DBAL\Driver\SQLite3;
|
||||
|
||||
use Doctrine\DBAL\Driver\Exception\UnknownParameterType;
|
||||
use Doctrine\DBAL\Driver\Statement as StatementInterface;
|
||||
use Doctrine\DBAL\ParameterType;
|
||||
use Doctrine\Deprecations\Deprecation;
|
||||
use SQLite3;
|
||||
use SQLite3Stmt;
|
||||
|
||||
use function assert;
|
||||
use function func_num_args;
|
||||
use function is_int;
|
||||
|
||||
use const SQLITE3_BLOB;
|
||||
use const SQLITE3_INTEGER;
|
||||
use const SQLITE3_NULL;
|
||||
use const SQLITE3_TEXT;
|
||||
|
||||
final class Statement implements StatementInterface
|
||||
{
|
||||
private const PARAM_TYPE_MAP = [
|
||||
ParameterType::NULL => SQLITE3_NULL,
|
||||
ParameterType::INTEGER => SQLITE3_INTEGER,
|
||||
ParameterType::STRING => SQLITE3_TEXT,
|
||||
ParameterType::ASCII => SQLITE3_TEXT,
|
||||
ParameterType::BINARY => SQLITE3_BLOB,
|
||||
ParameterType::LARGE_OBJECT => SQLITE3_BLOB,
|
||||
ParameterType::BOOLEAN => SQLITE3_INTEGER,
|
||||
];
|
||||
|
||||
private SQLite3 $connection;
|
||||
private SQLite3Stmt $statement;
|
||||
|
||||
/** @internal The statement can be only instantiated by its driver connection. */
|
||||
public function __construct(SQLite3 $connection, SQLite3Stmt $statement)
|
||||
{
|
||||
$this->connection = $connection;
|
||||
$this->statement = $statement;
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
public function bindValue($param, $value, $type = ParameterType::STRING): bool
|
||||
{
|
||||
if (func_num_args() < 3) {
|
||||
Deprecation::trigger(
|
||||
'doctrine/dbal',
|
||||
'https://github.com/doctrine/dbal/pull/5558',
|
||||
'Not passing $type to Statement::bindValue() is deprecated.'
|
||||
. ' Pass the type corresponding to the parameter being bound.',
|
||||
);
|
||||
}
|
||||
|
||||
return $this->statement->bindValue($param, $value, $this->convertParamType($type));
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
public function bindParam($param, &$variable, $type = ParameterType::STRING, $length = null): bool
|
||||
{
|
||||
Deprecation::trigger(
|
||||
'doctrine/dbal',
|
||||
'https://github.com/doctrine/dbal/pull/5563',
|
||||
'%s is deprecated. Use bindValue() instead.',
|
||||
__METHOD__,
|
||||
);
|
||||
|
||||
if (func_num_args() < 3) {
|
||||
Deprecation::trigger(
|
||||
'doctrine/dbal',
|
||||
'https://github.com/doctrine/dbal/pull/5558',
|
||||
'Not passing $type to Statement::bindParam() is deprecated.'
|
||||
. ' Pass the type corresponding to the parameter being bound.',
|
||||
);
|
||||
}
|
||||
|
||||
return $this->statement->bindParam($param, $variable, $this->convertParamType($type));
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
public function execute($params = null): Result
|
||||
{
|
||||
if ($params !== null) {
|
||||
Deprecation::trigger(
|
||||
'doctrine/dbal',
|
||||
'https://github.com/doctrine/dbal/pull/5556',
|
||||
'Passing $params to Statement::execute() is deprecated. Bind parameters using'
|
||||
. ' Statement::bindParam() or Statement::bindValue() instead.',
|
||||
);
|
||||
|
||||
foreach ($params as $param => $value) {
|
||||
if (is_int($param)) {
|
||||
$this->bindValue($param + 1, $value, ParameterType::STRING);
|
||||
} else {
|
||||
$this->bindValue($param, $value, ParameterType::STRING);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
$result = $this->statement->execute();
|
||||
} catch (\Exception $e) {
|
||||
throw Exception::new($e);
|
||||
}
|
||||
|
||||
assert($result !== false);
|
||||
|
||||
return new Result($result, $this->connection->changes());
|
||||
}
|
||||
|
||||
private function convertParamType(int $type): int
|
||||
{
|
||||
if (! isset(self::PARAM_TYPE_MAP[$type])) {
|
||||
throw UnknownParameterType::new($type);
|
||||
}
|
||||
|
||||
return self::PARAM_TYPE_MAP[$type];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user