updated-packages
This commit is contained in:
@@ -3,13 +3,19 @@
|
||||
namespace Doctrine\DBAL\Query;
|
||||
|
||||
use Doctrine\DBAL\Connection;
|
||||
use Doctrine\DBAL\Driver\Statement;
|
||||
use Doctrine\DBAL\Exception;
|
||||
use Doctrine\DBAL\ForwardCompatibility;
|
||||
use Doctrine\DBAL\ParameterType;
|
||||
use Doctrine\DBAL\Query\Expression\CompositeExpression;
|
||||
use Doctrine\DBAL\Query\Expression\ExpressionBuilder;
|
||||
use Doctrine\DBAL\Types\Type;
|
||||
use Doctrine\Deprecations\Deprecation;
|
||||
|
||||
use function array_filter;
|
||||
use function array_key_exists;
|
||||
use function array_keys;
|
||||
use function array_unshift;
|
||||
use function count;
|
||||
use function func_get_args;
|
||||
use function func_num_args;
|
||||
use function implode;
|
||||
@@ -52,41 +58,47 @@ class QueryBuilder
|
||||
*/
|
||||
private $connection;
|
||||
|
||||
/*
|
||||
* The default values of SQL parts collection
|
||||
*/
|
||||
private const SQL_PARTS_DEFAULTS = [
|
||||
'select' => [],
|
||||
'distinct' => false,
|
||||
'from' => [],
|
||||
'join' => [],
|
||||
'set' => [],
|
||||
'where' => null,
|
||||
'groupBy' => [],
|
||||
'having' => null,
|
||||
'orderBy' => [],
|
||||
'values' => [],
|
||||
];
|
||||
|
||||
/**
|
||||
* The array of SQL parts collected.
|
||||
*
|
||||
* @var mixed[]
|
||||
*/
|
||||
private $sqlParts = [
|
||||
'select' => [],
|
||||
'from' => [],
|
||||
'join' => [],
|
||||
'set' => [],
|
||||
'where' => null,
|
||||
'groupBy' => [],
|
||||
'having' => null,
|
||||
'orderBy' => [],
|
||||
'values' => [],
|
||||
];
|
||||
private $sqlParts = self::SQL_PARTS_DEFAULTS;
|
||||
|
||||
/**
|
||||
* The complete SQL string for this query.
|
||||
*
|
||||
* @var string
|
||||
* @var string|null
|
||||
*/
|
||||
private $sql;
|
||||
|
||||
/**
|
||||
* The query parameters.
|
||||
*
|
||||
* @var mixed[]
|
||||
* @var array<int, mixed>|array<string, mixed>
|
||||
*/
|
||||
private $params = [];
|
||||
|
||||
/**
|
||||
* The parameter type map of this query.
|
||||
*
|
||||
* @var int[]|string[]
|
||||
* @var array<int, int|string|Type|null>|array<string, int|string|Type|null>
|
||||
*/
|
||||
private $paramTypes = [];
|
||||
|
||||
@@ -109,14 +121,14 @@ class QueryBuilder
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $firstResult = null;
|
||||
private $firstResult = 0;
|
||||
|
||||
/**
|
||||
* The maximum number of results to retrieve.
|
||||
* The maximum number of results to retrieve or NULL to retrieve all results.
|
||||
*
|
||||
* @var int
|
||||
* @var int|null
|
||||
*/
|
||||
private $maxResults = null;
|
||||
private $maxResults;
|
||||
|
||||
/**
|
||||
* The counter of bound parameters used with {@see bindValue).
|
||||
@@ -189,18 +201,19 @@ class QueryBuilder
|
||||
/**
|
||||
* 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 ForwardCompatibility\Result|int|string
|
||||
*
|
||||
* @return Statement|int
|
||||
* @throws Exception
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
if ($this->type === self::SELECT) {
|
||||
return $this->connection->executeQuery($this->getSQL(), $this->params, $this->paramTypes);
|
||||
return ForwardCompatibility\Result::ensure(
|
||||
$this->connection->executeQuery($this->getSQL(), $this->params, $this->paramTypes)
|
||||
);
|
||||
}
|
||||
|
||||
return $this->connection->executeUpdate($this->getSQL(), $this->params, $this->paramTypes);
|
||||
return $this->connection->executeStatement($this->getSQL(), $this->params, $this->paramTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -225,6 +238,7 @@ class QueryBuilder
|
||||
case self::INSERT:
|
||||
$sql = $this->getSQLForInsert();
|
||||
break;
|
||||
|
||||
case self::DELETE:
|
||||
$sql = $this->getSQLForDelete();
|
||||
break;
|
||||
@@ -256,9 +270,9 @@ class QueryBuilder
|
||||
* ->setParameter(':user_id', 1);
|
||||
* </code>
|
||||
*
|
||||
* @param string|int $key The parameter position or name.
|
||||
* @param mixed $value The parameter value.
|
||||
* @param string|int|null $type One of the {@link \Doctrine\DBAL\ParameterType} constants.
|
||||
* @param int|string $key Parameter position or name
|
||||
* @param mixed $value Parameter value
|
||||
* @param int|string|Type|null $type Parameter type
|
||||
*
|
||||
* @return $this This QueryBuilder instance.
|
||||
*/
|
||||
@@ -287,8 +301,8 @@ class QueryBuilder
|
||||
* ));
|
||||
* </code>
|
||||
*
|
||||
* @param mixed[] $params The query parameters to set.
|
||||
* @param int[]|string[] $types The query parameters types to set.
|
||||
* @param array<int, mixed>|array<string, mixed> $params Parameters to set
|
||||
* @param array<int, int|string|Type|null>|array<string, int|string|Type|null> $types Parameter types
|
||||
*
|
||||
* @return $this This QueryBuilder instance.
|
||||
*/
|
||||
@@ -303,7 +317,7 @@ class QueryBuilder
|
||||
/**
|
||||
* Gets all defined query parameters for the query being constructed indexed by parameter index or name.
|
||||
*
|
||||
* @return mixed[] The currently defined query parameters indexed by parameter index or name.
|
||||
* @return array<int, mixed>|array<string, mixed> The currently defined query parameters
|
||||
*/
|
||||
public function getParameters()
|
||||
{
|
||||
@@ -325,7 +339,8 @@ class QueryBuilder
|
||||
/**
|
||||
* Gets all defined query parameter types for the query being constructed indexed by parameter index or name.
|
||||
*
|
||||
* @return int[]|string[] The currently defined query parameter types indexed by parameter index or name.
|
||||
* @return array<int, int|string|Type|null>|array<string, int|string|Type|null> The currently defined
|
||||
* query parameter types
|
||||
*/
|
||||
public function getParameterTypes()
|
||||
{
|
||||
@@ -335,9 +350,9 @@ class QueryBuilder
|
||||
/**
|
||||
* Gets a (previously set) query parameter type of the query being constructed.
|
||||
*
|
||||
* @param mixed $key The key (index or name) of the bound parameter type.
|
||||
* @param int|string $key The key of the bound parameter type
|
||||
*
|
||||
* @return mixed The value of the bound parameter type.
|
||||
* @return int|string|Type|null The value of the bound parameter type
|
||||
*/
|
||||
public function getParameterType($key)
|
||||
{
|
||||
@@ -361,7 +376,6 @@ class QueryBuilder
|
||||
|
||||
/**
|
||||
* Gets the position of the first result the query object was set to retrieve (the "offset").
|
||||
* Returns NULL if {@link setFirstResult} was not applied to this QueryBuilder.
|
||||
*
|
||||
* @return int The position of the first result.
|
||||
*/
|
||||
@@ -373,7 +387,7 @@ class QueryBuilder
|
||||
/**
|
||||
* Sets the maximum number of results to retrieve (the "limit").
|
||||
*
|
||||
* @param int $maxResults The maximum number of results to retrieve.
|
||||
* @param int|null $maxResults The maximum number of results to retrieve or NULL to retrieve all results.
|
||||
*
|
||||
* @return $this This QueryBuilder instance.
|
||||
*/
|
||||
@@ -387,9 +401,9 @@ class QueryBuilder
|
||||
|
||||
/**
|
||||
* Gets the maximum number of results the query object was set to retrieve (the "limit").
|
||||
* Returns NULL if {@link setMaxResults} was not applied to this query builder.
|
||||
* Returns NULL if all results will be returned.
|
||||
*
|
||||
* @return int The maximum number of results.
|
||||
* @return int|null The maximum number of results.
|
||||
*/
|
||||
public function getMaxResults()
|
||||
{
|
||||
@@ -403,7 +417,7 @@ class QueryBuilder
|
||||
* 'groupBy', 'having' and 'orderBy'.
|
||||
*
|
||||
* @param string $sqlPartName
|
||||
* @param string $sqlPart
|
||||
* @param mixed $sqlPart
|
||||
* @param bool $append
|
||||
*
|
||||
* @return $this This QueryBuilder instance.
|
||||
@@ -420,7 +434,12 @@ class QueryBuilder
|
||||
$this->state = self::STATE_DIRTY;
|
||||
|
||||
if ($append) {
|
||||
if ($sqlPartName === 'orderBy' || $sqlPartName === 'groupBy' || $sqlPartName === 'select' || $sqlPartName === 'set') {
|
||||
if (
|
||||
$sqlPartName === 'orderBy'
|
||||
|| $sqlPartName === 'groupBy'
|
||||
|| $sqlPartName === 'select'
|
||||
|| $sqlPartName === 'set'
|
||||
) {
|
||||
foreach ($sqlPart as $part) {
|
||||
$this->sqlParts[$sqlPartName][] = $part;
|
||||
}
|
||||
@@ -445,6 +464,8 @@ class QueryBuilder
|
||||
* Specifies an item that is to be returned in the query result.
|
||||
* Replaces any previously specified selections, if any.
|
||||
*
|
||||
* USING AN ARRAY ARGUMENT IS DEPRECATED. Pass each value as an individual argument.
|
||||
*
|
||||
* <code>
|
||||
* $qb = $conn->createQueryBuilder()
|
||||
* ->select('u.id', 'p.id')
|
||||
@@ -452,11 +473,12 @@ class QueryBuilder
|
||||
* ->leftJoin('u', 'phonenumbers', 'p', 'u.id = p.user_id');
|
||||
* </code>
|
||||
*
|
||||
* @param mixed $select The selection expressions.
|
||||
* @param string|string[]|null $select The selection expression. USING AN ARRAY OR NULL IS DEPRECATED.
|
||||
* Pass each value as an individual argument.
|
||||
*
|
||||
* @return $this This QueryBuilder instance.
|
||||
*/
|
||||
public function select($select = null)
|
||||
public function select($select = null/*, string ...$selects*/)
|
||||
{
|
||||
$this->type = self::SELECT;
|
||||
|
||||
@@ -464,14 +486,44 @@ class QueryBuilder
|
||||
return $this;
|
||||
}
|
||||
|
||||
if (is_array($select)) {
|
||||
Deprecation::trigger(
|
||||
'doctrine/dbal',
|
||||
'https://github.com/doctrine/dbal/issues/3837',
|
||||
'Passing an array for the first argument to QueryBuilder::select is deprecated, ' .
|
||||
'pass each value as an individual variadic argument instead.'
|
||||
);
|
||||
}
|
||||
|
||||
$selects = is_array($select) ? $select : func_get_args();
|
||||
|
||||
return $this->add('select', $selects);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds DISTINCT to the query.
|
||||
*
|
||||
* <code>
|
||||
* $qb = $conn->createQueryBuilder()
|
||||
* ->select('u.id')
|
||||
* ->distinct()
|
||||
* ->from('users', 'u')
|
||||
* </code>
|
||||
*
|
||||
* @return $this This QueryBuilder instance.
|
||||
*/
|
||||
public function distinct(): self
|
||||
{
|
||||
$this->sqlParts['distinct'] = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an item that is to be returned in the query result.
|
||||
*
|
||||
* USING AN ARRAY ARGUMENT IS DEPRECATED. Pass each value as an individual argument.
|
||||
*
|
||||
* <code>
|
||||
* $qb = $conn->createQueryBuilder()
|
||||
* ->select('u.id')
|
||||
@@ -480,11 +532,12 @@ class QueryBuilder
|
||||
* ->leftJoin('u', 'phonenumbers', 'u.id = p.user_id');
|
||||
* </code>
|
||||
*
|
||||
* @param mixed $select The selection expression.
|
||||
* @param string|string[]|null $select The selection expression. USING AN ARRAY OR NULL IS DEPRECATED.
|
||||
* Pass each value as an individual argument.
|
||||
*
|
||||
* @return $this This QueryBuilder instance.
|
||||
*/
|
||||
public function addSelect($select = null)
|
||||
public function addSelect($select = null/*, string ...$selects*/)
|
||||
{
|
||||
$this->type = self::SELECT;
|
||||
|
||||
@@ -492,6 +545,15 @@ class QueryBuilder
|
||||
return $this;
|
||||
}
|
||||
|
||||
if (is_array($select)) {
|
||||
Deprecation::trigger(
|
||||
'doctrine/dbal',
|
||||
'https://github.com/doctrine/dbal/issues/3837',
|
||||
'Passing an array for the first argument to QueryBuilder::addSelect is deprecated, ' .
|
||||
'pass each value as an individual variadic argument instead.'
|
||||
);
|
||||
}
|
||||
|
||||
$selects = is_array($select) ? $select : func_get_args();
|
||||
|
||||
return $this->add('select', $selects, true);
|
||||
@@ -504,7 +566,7 @@ class QueryBuilder
|
||||
* <code>
|
||||
* $qb = $conn->createQueryBuilder()
|
||||
* ->delete('users', 'u')
|
||||
* ->where('u.id = :user_id');
|
||||
* ->where('u.id = :user_id')
|
||||
* ->setParameter(':user_id', 1);
|
||||
* </code>
|
||||
*
|
||||
@@ -768,7 +830,7 @@ class QueryBuilder
|
||||
public function where($predicates)
|
||||
{
|
||||
if (! (func_num_args() === 1 && $predicates instanceof CompositeExpression)) {
|
||||
$predicates = new CompositeExpression(CompositeExpression::TYPE_AND, func_get_args());
|
||||
$predicates = CompositeExpression::and(...func_get_args());
|
||||
}
|
||||
|
||||
return $this->add('where', $predicates);
|
||||
@@ -795,13 +857,16 @@ class QueryBuilder
|
||||
public function andWhere($where)
|
||||
{
|
||||
$args = func_get_args();
|
||||
$args = array_filter($args); // https://github.com/doctrine/dbal/issues/4282
|
||||
$where = $this->getQueryPart('where');
|
||||
|
||||
if ($where instanceof CompositeExpression && $where->getType() === CompositeExpression::TYPE_AND) {
|
||||
$where->addMultiple($args);
|
||||
if (count($args) > 0) {
|
||||
$where = $where->with(...$args);
|
||||
}
|
||||
} else {
|
||||
array_unshift($args, $where);
|
||||
$where = new CompositeExpression(CompositeExpression::TYPE_AND, $args);
|
||||
$where = CompositeExpression::and(...$args);
|
||||
}
|
||||
|
||||
return $this->add('where', $where, true);
|
||||
@@ -828,13 +893,16 @@ class QueryBuilder
|
||||
public function orWhere($where)
|
||||
{
|
||||
$args = func_get_args();
|
||||
$args = array_filter($args); // https://github.com/doctrine/dbal/issues/4282
|
||||
$where = $this->getQueryPart('where');
|
||||
|
||||
if ($where instanceof CompositeExpression && $where->getType() === CompositeExpression::TYPE_OR) {
|
||||
$where->addMultiple($args);
|
||||
if (count($args) > 0) {
|
||||
$where = $where->with(...$args);
|
||||
}
|
||||
} else {
|
||||
array_unshift($args, $where);
|
||||
$where = new CompositeExpression(CompositeExpression::TYPE_OR, $args);
|
||||
$where = CompositeExpression::or(...$args);
|
||||
}
|
||||
|
||||
return $this->add('where', $where, true);
|
||||
@@ -844,6 +912,8 @@ class QueryBuilder
|
||||
* Specifies a grouping over the results of the query.
|
||||
* Replaces any previously specified groupings, if any.
|
||||
*
|
||||
* USING AN ARRAY ARGUMENT IS DEPRECATED. Pass each value as an individual argument.
|
||||
*
|
||||
* <code>
|
||||
* $qb = $conn->createQueryBuilder()
|
||||
* ->select('u.name')
|
||||
@@ -851,43 +921,64 @@ class QueryBuilder
|
||||
* ->groupBy('u.id');
|
||||
* </code>
|
||||
*
|
||||
* @param mixed $groupBy The grouping expression.
|
||||
* @param string|string[] $groupBy The grouping expression. USING AN ARRAY IS DEPRECATED.
|
||||
* Pass each value as an individual argument.
|
||||
*
|
||||
* @return $this This QueryBuilder instance.
|
||||
*/
|
||||
public function groupBy($groupBy)
|
||||
public function groupBy($groupBy/*, string ...$groupBys*/)
|
||||
{
|
||||
if (empty($groupBy)) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
if (is_array($groupBy)) {
|
||||
Deprecation::trigger(
|
||||
'doctrine/dbal',
|
||||
'https://github.com/doctrine/dbal/issues/3837',
|
||||
'Passing an array for the first argument to QueryBuilder::groupBy is deprecated, ' .
|
||||
'pass each value as an individual variadic argument instead.'
|
||||
);
|
||||
}
|
||||
|
||||
$groupBy = is_array($groupBy) ? $groupBy : func_get_args();
|
||||
|
||||
return $this->add('groupBy', $groupBy, false);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds a grouping expression to the query.
|
||||
*
|
||||
* USING AN ARRAY ARGUMENT IS DEPRECATED. Pass each value as an individual argument.
|
||||
*
|
||||
* <code>
|
||||
* $qb = $conn->createQueryBuilder()
|
||||
* ->select('u.name')
|
||||
* ->from('users', 'u')
|
||||
* ->groupBy('u.lastLogin');
|
||||
* ->addGroupBy('u.createdAt')
|
||||
* ->groupBy('u.lastLogin')
|
||||
* ->addGroupBy('u.createdAt');
|
||||
* </code>
|
||||
*
|
||||
* @param mixed $groupBy The grouping expression.
|
||||
* @param string|string[] $groupBy The grouping expression. USING AN ARRAY IS DEPRECATED.
|
||||
* Pass each value as an individual argument.
|
||||
*
|
||||
* @return $this This QueryBuilder instance.
|
||||
*/
|
||||
public function addGroupBy($groupBy)
|
||||
public function addGroupBy($groupBy/*, string ...$groupBys*/)
|
||||
{
|
||||
if (empty($groupBy)) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
if (is_array($groupBy)) {
|
||||
Deprecation::trigger(
|
||||
'doctrine/dbal',
|
||||
'https://github.com/doctrine/dbal/issues/3837',
|
||||
'Passing an array for the first argument to QueryBuilder::addGroupBy is deprecated, ' .
|
||||
'pass each value as an individual variadic argument instead.'
|
||||
);
|
||||
}
|
||||
|
||||
$groupBy = is_array($groupBy) ? $groupBy : func_get_args();
|
||||
|
||||
return $this->add('groupBy', $groupBy, true);
|
||||
@@ -954,7 +1045,7 @@ class QueryBuilder
|
||||
public function having($having)
|
||||
{
|
||||
if (! (func_num_args() === 1 && $having instanceof CompositeExpression)) {
|
||||
$having = new CompositeExpression(CompositeExpression::TYPE_AND, func_get_args());
|
||||
$having = CompositeExpression::and(...func_get_args());
|
||||
}
|
||||
|
||||
return $this->add('having', $having);
|
||||
@@ -971,13 +1062,14 @@ class QueryBuilder
|
||||
public function andHaving($having)
|
||||
{
|
||||
$args = func_get_args();
|
||||
$args = array_filter($args); // https://github.com/doctrine/dbal/issues/4282
|
||||
$having = $this->getQueryPart('having');
|
||||
|
||||
if ($having instanceof CompositeExpression && $having->getType() === CompositeExpression::TYPE_AND) {
|
||||
$having->addMultiple($args);
|
||||
$having = $having->with(...$args);
|
||||
} else {
|
||||
array_unshift($args, $having);
|
||||
$having = new CompositeExpression(CompositeExpression::TYPE_AND, $args);
|
||||
$having = CompositeExpression::and(...$args);
|
||||
}
|
||||
|
||||
return $this->add('having', $having);
|
||||
@@ -994,13 +1086,14 @@ class QueryBuilder
|
||||
public function orHaving($having)
|
||||
{
|
||||
$args = func_get_args();
|
||||
$args = array_filter($args); // https://github.com/doctrine/dbal/issues/4282
|
||||
$having = $this->getQueryPart('having');
|
||||
|
||||
if ($having instanceof CompositeExpression && $having->getType() === CompositeExpression::TYPE_OR) {
|
||||
$having->addMultiple($args);
|
||||
$having = $having->with(...$args);
|
||||
} else {
|
||||
array_unshift($args, $having);
|
||||
$having = new CompositeExpression(CompositeExpression::TYPE_OR, $args);
|
||||
$having = CompositeExpression::or(...$args);
|
||||
}
|
||||
|
||||
return $this->add('having', $having);
|
||||
@@ -1084,8 +1177,7 @@ class QueryBuilder
|
||||
*/
|
||||
public function resetQueryPart($queryPartName)
|
||||
{
|
||||
$this->sqlParts[$queryPartName] = is_array($this->sqlParts[$queryPartName])
|
||||
? [] : null;
|
||||
$this->sqlParts[$queryPartName] = self::SQL_PARTS_DEFAULTS[$queryPartName];
|
||||
|
||||
$this->state = self::STATE_DIRTY;
|
||||
|
||||
@@ -1099,7 +1191,8 @@ class QueryBuilder
|
||||
*/
|
||||
private function getSQLForSelect()
|
||||
{
|
||||
$query = 'SELECT ' . implode(', ', $this->sqlParts['select']);
|
||||
$query = 'SELECT ' . ($this->sqlParts['distinct'] ? 'DISTINCT ' : '') .
|
||||
implode(', ', $this->sqlParts['select']);
|
||||
|
||||
$query .= ($this->sqlParts['from'] ? ' FROM ' . implode(', ', $this->getFromClauses()) : '')
|
||||
. ($this->sqlParts['where'] !== null ? ' WHERE ' . ((string) $this->sqlParts['where']) : '')
|
||||
@@ -1147,11 +1240,11 @@ class QueryBuilder
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $knownAliases
|
||||
* @param array<string,true> $knownAliases
|
||||
*
|
||||
* @throws QueryException
|
||||
*/
|
||||
private function verifyAllAliasesAreKnown(array $knownAliases)
|
||||
private function verifyAllAliasesAreKnown(array $knownAliases): void
|
||||
{
|
||||
foreach ($this->sqlParts['join'] as $fromAlias => $joins) {
|
||||
if (! isset($knownAliases[$fromAlias])) {
|
||||
@@ -1165,7 +1258,7 @@ class QueryBuilder
|
||||
*/
|
||||
private function isLimitQuery()
|
||||
{
|
||||
return $this->maxResults !== null || $this->firstResult !== null;
|
||||
return $this->maxResults !== null || $this->firstResult !== 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1187,7 +1280,9 @@ class QueryBuilder
|
||||
*/
|
||||
private function getSQLForUpdate()
|
||||
{
|
||||
$table = $this->sqlParts['from']['table'] . ($this->sqlParts['from']['alias'] ? ' ' . $this->sqlParts['from']['alias'] : '');
|
||||
$table = $this->sqlParts['from']['table']
|
||||
. ($this->sqlParts['from']['alias'] ? ' ' . $this->sqlParts['from']['alias'] : '');
|
||||
|
||||
return 'UPDATE ' . $table
|
||||
. ' SET ' . implode(', ', $this->sqlParts['set'])
|
||||
. ($this->sqlParts['where'] !== null ? ' WHERE ' . ((string) $this->sqlParts['where']) : '');
|
||||
@@ -1200,8 +1295,11 @@ class QueryBuilder
|
||||
*/
|
||||
private function getSQLForDelete()
|
||||
{
|
||||
$table = $this->sqlParts['from']['table'] . ($this->sqlParts['from']['alias'] ? ' ' . $this->sqlParts['from']['alias'] : '');
|
||||
return 'DELETE FROM ' . $table . ($this->sqlParts['where'] !== null ? ' WHERE ' . ((string) $this->sqlParts['where']) : '');
|
||||
$table = $this->sqlParts['from']['table']
|
||||
. ($this->sqlParts['from']['alias'] ? ' ' . $this->sqlParts['from']['alias'] : '');
|
||||
|
||||
return 'DELETE FROM ' . $table
|
||||
. ($this->sqlParts['where'] !== null ? ' WHERE ' . ((string) $this->sqlParts['where']) : '');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1237,9 +1335,9 @@ class QueryBuilder
|
||||
*
|
||||
* @link http://www.zetacomponents.org
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param mixed $type
|
||||
* @param string $placeHolder The name to bind with. The string must start with a colon ':'.
|
||||
* @param mixed $value
|
||||
* @param int|string|Type|null $type
|
||||
* @param string $placeHolder The name to bind with. The string must start with a colon ':'.
|
||||
*
|
||||
* @return string the placeholder name used.
|
||||
*/
|
||||
@@ -1249,6 +1347,7 @@ class QueryBuilder
|
||||
$this->boundCounter++;
|
||||
$placeHolder = ':dcValue' . $this->boundCounter;
|
||||
}
|
||||
|
||||
$this->setParameter(substr($placeHolder, 1), $value, $type);
|
||||
|
||||
return $placeHolder;
|
||||
@@ -1271,8 +1370,8 @@ class QueryBuilder
|
||||
* ->orWhere('u.username = ' . $qb->createPositionalParameter('Bar', ParameterType::STRING))
|
||||
* </code>
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param int $type
|
||||
* @param mixed $value
|
||||
* @param int|string|Type|null $type
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@@ -1285,8 +1384,8 @@ class QueryBuilder
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $fromAlias
|
||||
* @param string[] $knownAliases
|
||||
* @param string $fromAlias
|
||||
* @param array<string,true> $knownAliases
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
@@ -1301,9 +1400,13 @@ class QueryBuilder
|
||||
if (array_key_exists($join['joinAlias'], $knownAliases)) {
|
||||
throw QueryException::nonUniqueAlias($join['joinAlias'], array_keys($knownAliases));
|
||||
}
|
||||
$sql .= ' ' . strtoupper($join['joinType'])
|
||||
. ' JOIN ' . $join['joinTable'] . ' ' . $join['joinAlias']
|
||||
. ' ON ' . ((string) $join['joinCondition']);
|
||||
|
||||
$sql .= ' ' . strtoupper($join['joinType'])
|
||||
. ' JOIN ' . $join['joinTable'] . ' ' . $join['joinAlias'];
|
||||
if ($join['joinCondition'] !== null) {
|
||||
$sql .= ' ON ' . $join['joinCondition'];
|
||||
}
|
||||
|
||||
$knownAliases[$join['joinAlias']] = true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user