Update website

This commit is contained in:
Guilhem Lavaux 2024-11-19 08:02:04 +01:00
parent 4413528994
commit 1d90fbf296
6865 changed files with 1091082 additions and 0 deletions

View file

@ -0,0 +1,85 @@
<?php
namespace Doctrine\DBAL\SQL\Builder;
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\Sequence;
use Doctrine\DBAL\Schema\Table;
use function array_merge;
final class CreateSchemaObjectsSQLBuilder
{
private AbstractPlatform $platform;
public function __construct(AbstractPlatform $platform)
{
$this->platform = $platform;
}
/**
* @return list<string>
*
* @throws Exception
*/
public function buildSQL(Schema $schema): array
{
return array_merge(
$this->buildNamespaceStatements($schema->getNamespaces()),
$this->buildSequenceStatements($schema->getSequences()),
$this->buildTableStatements($schema->getTables()),
);
}
/**
* @param list<string> $namespaces
*
* @return list<string>
*
* @throws Exception
*/
private function buildNamespaceStatements(array $namespaces): array
{
$statements = [];
if ($this->platform->supportsSchemas()) {
foreach ($namespaces as $namespace) {
$statements[] = $this->platform->getCreateSchemaSQL($namespace);
}
}
return $statements;
}
/**
* @param list<Table> $tables
*
* @return list<string>
*
* @throws Exception
*/
private function buildTableStatements(array $tables): array
{
return $this->platform->getCreateTablesSQL($tables);
}
/**
* @param list<Sequence> $sequences
*
* @return list<string>
*
* @throws Exception
*/
private function buildSequenceStatements(array $sequences): array
{
$statements = [];
foreach ($sequences as $sequence) {
$statements[] = $this->platform->getCreateSequenceSQL($sequence);
}
return $statements;
}
}

View file

@ -0,0 +1,95 @@
<?php
namespace Doctrine\DBAL\SQL\Builder;
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Query\ForUpdate\ConflictResolutionMode;
use Doctrine\DBAL\Query\SelectQuery;
use function count;
use function implode;
final class DefaultSelectSQLBuilder implements SelectSQLBuilder
{
private AbstractPlatform $platform;
private ?string $forUpdateSQL;
private ?string $skipLockedSQL;
/** @internal The SQL builder should be instantiated only by database platforms. */
public function __construct(AbstractPlatform $platform, ?string $forUpdateSQL, ?string $skipLockedSQL)
{
$this->platform = $platform;
$this->forUpdateSQL = $forUpdateSQL;
$this->skipLockedSQL = $skipLockedSQL;
}
/** @throws Exception */
public function buildSQL(SelectQuery $query): string
{
$parts = ['SELECT'];
if ($query->isDistinct()) {
$parts[] = 'DISTINCT';
}
$parts[] = implode(', ', $query->getColumns());
$from = $query->getFrom();
if (count($from) > 0) {
$parts[] = 'FROM ' . implode(', ', $from);
}
$where = $query->getWhere();
if ($where !== null) {
$parts[] = 'WHERE ' . $where;
}
$groupBy = $query->getGroupBy();
if (count($groupBy) > 0) {
$parts[] = 'GROUP BY ' . implode(', ', $groupBy);
}
$having = $query->getHaving();
if ($having !== null) {
$parts[] = 'HAVING ' . $having;
}
$orderBy = $query->getOrderBy();
if (count($orderBy) > 0) {
$parts[] = 'ORDER BY ' . implode(', ', $orderBy);
}
$sql = implode(' ', $parts);
$limit = $query->getLimit();
if ($limit->isDefined()) {
$sql = $this->platform->modifyLimitQuery($sql, $limit->getMaxResults(), $limit->getFirstResult());
}
$forUpdate = $query->getForUpdate();
if ($forUpdate !== null) {
if ($this->forUpdateSQL === null) {
throw Exception::notSupported('FOR UPDATE');
}
$sql .= ' ' . $this->forUpdateSQL;
if ($forUpdate->getConflictResolutionMode() === ConflictResolutionMode::SKIP_LOCKED) {
if ($this->skipLockedSQL === null) {
throw Exception::notSupported('SKIP LOCKED');
}
$sql .= ' ' . $this->skipLockedSQL;
}
}
return $sql;
}
}

View file

@ -0,0 +1,62 @@
<?php
namespace Doctrine\DBAL\SQL\Builder;
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Schema\Sequence;
use Doctrine\DBAL\Schema\Table;
use function array_merge;
final class DropSchemaObjectsSQLBuilder
{
private AbstractPlatform $platform;
public function __construct(AbstractPlatform $platform)
{
$this->platform = $platform;
}
/**
* @return list<string>
*
* @throws Exception
*/
public function buildSQL(Schema $schema): array
{
return array_merge(
$this->buildSequenceStatements($schema->getSequences()),
$this->buildTableStatements($schema->getTables()),
);
}
/**
* @param list<Table> $tables
*
* @return list<string>
*/
private function buildTableStatements(array $tables): array
{
return $this->platform->getDropTablesSQL($tables);
}
/**
* @param list<Sequence> $sequences
*
* @return list<string>
*
* @throws Exception
*/
private function buildSequenceStatements(array $sequences): array
{
$statements = [];
foreach ($sequences as $sequence) {
$statements[] = $this->platform->getDropSequenceSQL($sequence);
}
return $statements;
}
}

View file

@ -0,0 +1,12 @@
<?php
namespace Doctrine\DBAL\SQL\Builder;
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Query\SelectQuery;
interface SelectSQLBuilder
{
/** @throws Exception */
public function buildSQL(SelectQuery $query): string;
}