Abstract Class Yiisoft\Db\QueryBuilder\AbstractQueryBuilder
| Inheritance | Yiisoft\Db\QueryBuilder\AbstractQueryBuilder |
|---|---|
| Implements | Yiisoft\Db\QueryBuilder\QueryBuilderInterface |
Builds a SELECT SQL statement based on the specification given as a Yiisoft\Db\Query\QueryInterface object.
SQL statements are created from Yiisoft\Db\Query\QueryInterface objects using the Yiisoft\Db\QueryBuilder\AbstractDQLQueryBuilder::build()-method.
AbstractQueryBuilder is also used by Yiisoft\Db\Command\CommandInterface to build SQL statements such as insert(), update(), delete() and createTable().
Protected Properties
| Property | Type | Description | Defined By |
|---|---|---|---|
| $typeMap | array | Yiisoft\Db\QueryBuilder\AbstractQueryBuilder |
Public Methods
Protected Methods
| Method | Description | Defined By |
|---|---|---|
| createSqlParser() | Creates an instance of Yiisoft\Db\Syntax\AbstractSqlParser for the given SQL expression. | Yiisoft\Db\QueryBuilder\AbstractQueryBuilder |
| prepareBinary() | Converts a binary value to its SQL representation using hexadecimal encoding. | Yiisoft\Db\QueryBuilder\AbstractQueryBuilder |
| prepareResource() | Converts a resource value to its SQL representation or throws an exception if conversion is not possible. | Yiisoft\Db\QueryBuilder\AbstractQueryBuilder |
Constants
| Constant | Value | Description | Defined By |
|---|---|---|---|
| FALSE_VALUE | 'FALSE' | Yiisoft\Db\QueryBuilder\AbstractQueryBuilder | |
| PARAM_PREFIX | ':qp' | The prefix for automatically generated query binding parameters. | Yiisoft\Db\QueryBuilder\AbstractQueryBuilder |
| TRUE_VALUE | 'TRUE' | Yiisoft\Db\QueryBuilder\AbstractQueryBuilder |
Property Details
Method Details
| public __construct( Yiisoft\Db\Connection\ConnectionInterface $db, Yiisoft\Db\QueryBuilder\AbstractDDLQueryBuilder $ddlBuilder, Yiisoft\Db\QueryBuilder\AbstractDMLQueryBuilder $dmlBuilder, Yiisoft\Db\QueryBuilder\AbstractDQLQueryBuilder $dqlBuilder, Yiisoft\Db\QueryBuilder\AbstractColumnDefinitionBuilder $columnDefinitionBuilder ): mixed | ||
| $db | Yiisoft\Db\Connection\ConnectionInterface | |
| $ddlBuilder | Yiisoft\Db\QueryBuilder\AbstractDDLQueryBuilder | |
| $dmlBuilder | Yiisoft\Db\QueryBuilder\AbstractDMLQueryBuilder | |
| $dqlBuilder | Yiisoft\Db\QueryBuilder\AbstractDQLQueryBuilder | |
| $columnDefinitionBuilder | Yiisoft\Db\QueryBuilder\AbstractColumnDefinitionBuilder | |
public function __construct(
private readonly ConnectionInterface $db,
private readonly AbstractDDLQueryBuilder $ddlBuilder,
private AbstractDMLQueryBuilder $dmlBuilder,
private readonly AbstractDQLQueryBuilder $dqlBuilder,
private readonly AbstractColumnDefinitionBuilder $columnDefinitionBuilder,
) {}
| public addCheck( string $table, string $name, string $expression ): string | ||
| $table | string | |
| $name | string | |
| $expression | string | |
public function addCheck(string $table, string $name, string $expression): string
{
return $this->ddlBuilder->addCheck($table, $name, $expression);
}
| public addColumn( string $table, string $column, Yiisoft\Db\Schema\Column\ColumnInterface|string $type ): string | ||
| $table | string | |
| $column | string | |
| $type | Yiisoft\Db\Schema\Column\ColumnInterface|string | |
public function addColumn(string $table, string $column, ColumnInterface|string $type): string
{
return $this->ddlBuilder->addColumn($table, $column, $type);
}
| public addCommentOnColumn( string $table, string $column, string $comment ): string | ||
| $table | string | |
| $column | string | |
| $comment | string | |
public function addCommentOnColumn(string $table, string $column, string $comment): string
{
return $this->ddlBuilder->addCommentOnColumn($table, $column, $comment);
}
| public addCommentOnTable( string $table, string $comment ): string | ||
| $table | string | |
| $comment | string | |
public function addCommentOnTable(string $table, string $comment): string
{
return $this->ddlBuilder->addCommentOnTable($table, $comment);
}
| public addDefaultValue( string $table, string $name, string $column, mixed $value ): string | ||
| $table | string | |
| $name | string | |
| $column | string | |
| $value | mixed | |
public function addDefaultValue(string $table, string $name, string $column, mixed $value): string
{
return $this->ddlBuilder->addDefaultValue($table, $name, $column, $value);
}
| public addForeignKey( string $table, string $name, array|string $columns, string $referenceTable, array|string $referenceColumns, string|null $delete = null, string|null $update = null ): string | ||
| $table | string | |
| $name | string | |
| $columns | array|string | |
| $referenceTable | string | |
| $referenceColumns | array|string | |
| $delete | string|null | |
| $update | string|null | |
public function addForeignKey(
string $table,
string $name,
array|string $columns,
string $referenceTable,
array|string $referenceColumns,
?string $delete = null,
?string $update = null,
): string {
return $this->ddlBuilder->addForeignKey(
$table,
$name,
$columns,
$referenceTable,
$referenceColumns,
$delete,
$update,
);
}
| public addPrimaryKey( string $table, string $name, array|string $columns ): string | ||
| $table | string | |
| $name | string | |
| $columns | array|string | |
public function addPrimaryKey(string $table, string $name, array|string $columns): string
{
return $this->ddlBuilder->addPrimaryKey($table, $name, $columns);
}
| public addUnique( string $table, string $name, array|string $columns ): string | ||
| $table | string | |
| $name | string | |
| $columns | array|string | |
public function addUnique(string $table, string $name, array|string $columns): string
{
return $this->ddlBuilder->addUnique($table, $name, $columns);
}
| public alterColumn( string $table, string $column, Yiisoft\Db\Schema\Column\ColumnInterface|string $type ): string | ||
| $table | string | |
| $column | string | |
| $type | Yiisoft\Db\Schema\Column\ColumnInterface|string | |
public function alterColumn(string $table, string $column, ColumnInterface|string $type): string
{
return $this->ddlBuilder->alterColumn($table, $column, $type);
}
| public bindParam( mixed $value, array &$params = [] ): string | ||
| $value | mixed | |
| $params | array | |
public function bindParam(mixed $value, array &$params = []): string
{
$phName = self::PARAM_PREFIX . count($params);
$additionalCount = 0;
while (isset($params[$phName])) {
$phName = self::PARAM_PREFIX . count($params) . '_' . $additionalCount;
++$additionalCount;
}
$params[$phName] = $value;
return $phName;
}
| public build( Yiisoft\Db\Query\QueryInterface $query, array $params = [] ): array | ||
| $query | Yiisoft\Db\Query\QueryInterface | |
| $params | array | |
public function build(QueryInterface $query, array $params = []): array
{
return $this->dqlBuilder->build($query, $params);
}
| public buildColumnDefinition( Yiisoft\Db\Schema\Column\ColumnInterface|string $column ): string | ||
| $column | Yiisoft\Db\Schema\Column\ColumnInterface|string | |
public function buildColumnDefinition(ColumnInterface|string $column): string
{
if (is_string($column)) {
$column = $this->db->getColumnFactory()->fromDefinition($column);
}
return $this->columnDefinitionBuilder->build($column);
}
| public buildColumns( array|string $columns ): string | ||
| $columns | array|string | |
public function buildColumns(array|string $columns): string
{
return $this->dqlBuilder->buildColumns($columns);
}
| public buildCondition( array|string|Yiisoft\Db\Expression\ExpressionInterface|null $condition, array &$params = [] ): string | ||
| $condition | array|string|Yiisoft\Db\Expression\ExpressionInterface|null | |
| $params | array | |
public function buildCondition(array|string|ExpressionInterface|null $condition, array &$params = []): string
{
return $this->dqlBuilder->buildCondition($condition, $params);
}
| public buildExpression( Yiisoft\Db\Expression\ExpressionInterface $expression, array &$params = [] ): string | ||
| $expression | Yiisoft\Db\Expression\ExpressionInterface | |
| $params | array | |
public function buildExpression(ExpressionInterface $expression, array &$params = []): string
{
return $this->dqlBuilder->buildExpression($expression, $params);
}
| public buildFor( array $values ): string | ||
| $values | array | |
public function buildFor(array $values): string
{
return $this->dqlBuilder->buildFor($values);
}
| public buildFrom( array $tables, array &$params ): string | ||
| $tables | array | |
| $params | array | |
public function buildFrom(array $tables, array &$params): string
{
return $this->dqlBuilder->buildFrom($tables, $params);
}
| public buildGroupBy( array $columns, array &$params = [] ): string | ||
| $columns | array | |
| $params | array | |
public function buildGroupBy(array $columns, array &$params = []): string
{
return $this->dqlBuilder->buildGroupBy($columns, $params);
}
| public buildHaving( array|Yiisoft\Db\Expression\ExpressionInterface|string|null $condition, array &$params = [] ): string | ||
| $condition | array|Yiisoft\Db\Expression\ExpressionInterface|string|null | |
| $params | array | |
public function buildHaving(array|ExpressionInterface|string|null $condition, array &$params = []): string
{
return $this->dqlBuilder->buildHaving($condition, $params);
}
| public buildJoin( array $joins, array &$params ): string | ||
| $joins | array | |
| $params | array | |
public function buildJoin(array $joins, array &$params): string
{
return $this->dqlBuilder->buildJoin($joins, $params);
}
public function buildLimit(ExpressionInterface|int|null $limit, ExpressionInterface|int|null $offset): string
{
return $this->dqlBuilder->buildLimit($limit, $offset);
}
| public buildOrderBy( array $columns, array &$params = [] ): string | ||
| $columns | array | |
| $params | array | |
public function buildOrderBy(array $columns, array &$params = []): string
{
return $this->dqlBuilder->buildOrderBy($columns, $params);
}
| public buildOrderByAndLimit( string $sql, array $orderBy, Yiisoft\Db\Expression\ExpressionInterface|integer|null $limit, Yiisoft\Db\Expression\ExpressionInterface|integer|null $offset, array &$params = [] ): string | ||
| $sql | string | |
| $orderBy | array | |
| $limit | Yiisoft\Db\Expression\ExpressionInterface|integer|null | |
| $offset | Yiisoft\Db\Expression\ExpressionInterface|integer|null | |
| $params | array | |
public function buildOrderByAndLimit(
string $sql,
array $orderBy,
ExpressionInterface|int|null $limit,
ExpressionInterface|int|null $offset,
array &$params = [],
): string {
return $this->dqlBuilder->buildOrderByAndLimit($sql, $orderBy, $limit, $offset, $params);
}
| public buildSelect( array $columns, array &$params, boolean $distinct = false, string|null $selectOption = null ): string | ||
| $columns | array | |
| $params | array | |
| $distinct | boolean | |
| $selectOption | string|null | |
public function buildSelect(
array $columns,
array &$params,
bool $distinct = false,
?string $selectOption = null,
): string {
return $this->dqlBuilder->buildSelect($columns, $params, $distinct, $selectOption);
}
| public buildUnion( array $unions, array &$params ): string | ||
| $unions | array | |
| $params | array | |
public function buildUnion(array $unions, array &$params): string
{
return $this->dqlBuilder->buildUnion($unions, $params);
}
| public buildValue( mixed $value, array &$params ): string | ||
| $value | mixed | |
| $params | array | |
public function buildValue(mixed $value, array &$params): string
{
/** @psalm-suppress MixedArgument */
return match (gettype($value)) {
GettypeResult::ARRAY => $this->buildExpression(
array_is_list($value) ? new ArrayValue($value) : new JsonValue($value),
$params,
),
GettypeResult::BOOLEAN => $value ? static::TRUE_VALUE : static::FALSE_VALUE,
GettypeResult::DOUBLE => (string) $value,
GettypeResult::INTEGER => (string) $value,
GettypeResult::NULL => 'NULL',
GettypeResult::OBJECT => match (true) {
$value instanceof Param => $this->bindParam($value, $params),
$value instanceof ExpressionInterface => $this->buildExpression($value, $params),
$value instanceof StringableStream => $this->bindParam(new Param($value->getValue(), DataType::LOB), $params),
$value instanceof Stringable => $this->bindParam(new Param((string) $value, DataType::STRING), $params),
$value instanceof BackedEnum => is_string($value->value)
? $this->bindParam(new Param($value->value, DataType::STRING), $params)
: (string) $value->value,
$value instanceof Iterator && $value->key() === 0 => $this->buildExpression(new ArrayValue($value), $params),
$value instanceof Traversable => $this->buildExpression(new JsonValue($value), $params),
$value instanceof JsonSerializable => $this->buildExpression(new JsonValue($value), $params),
default => $this->bindParam($value, $params),
},
GettypeResult::RESOURCE => $this->bindParam(new Param($value, DataType::LOB), $params),
GettypeResult::RESOURCE_CLOSED => throw new InvalidArgumentException('Resource is closed.'),
GettypeResult::STRING => $this->bindParam(new Param($value, DataType::STRING), $params),
default => $this->bindParam($value, $params),
};
}
| public buildWhere( array|string|Yiisoft\Db\QueryBuilder\Condition\ConditionInterface|Yiisoft\Db\Expression\ExpressionInterface|null $condition, array &$params = [] ): string | ||
| $condition | array|string|Yiisoft\Db\QueryBuilder\Condition\ConditionInterface|Yiisoft\Db\Expression\ExpressionInterface|null | |
| $params | array | |
public function buildWhere(
array|string|ConditionInterface|ExpressionInterface|null $condition,
array &$params = [],
): string {
return $this->dqlBuilder->buildWhere($condition, $params);
}
| public buildWithQueries( array $withQueries, array &$params ): string | ||
| $withQueries | array | |
| $params | array | |
public function buildWithQueries(array $withQueries, array &$params): string
{
return $this->dqlBuilder->buildWithQueries($withQueries, $params);
}
| public checkIntegrity( string $schema = '', string $table = '', boolean $check = true ): string | ||
| $schema | string | |
| $table | string | |
| $check | boolean | |
public function checkIntegrity(string $schema = '', string $table = '', bool $check = true): string
{
return $this->ddlBuilder->checkIntegrity($schema, $table, $check);
}
| public createConditionFromArray( array $condition ): Yiisoft\Db\QueryBuilder\Condition\ConditionInterface | ||
| $condition | array | |
public function createConditionFromArray(array $condition): ConditionInterface
{
return $this->dqlBuilder->createConditionFromArray($condition);
}
| public createIndex( string $table, string $name, array|string $columns, string|null $indexType = null, string|null $indexMethod = null ): string | ||
| $table | string | |
| $name | string | |
| $columns | array|string | |
| $indexType | string|null | |
| $indexMethod | string|null | |
public function createIndex(
string $table,
string $name,
array|string $columns,
?string $indexType = null,
?string $indexMethod = null,
): string {
return $this->ddlBuilder->createIndex($table, $name, $columns, $indexType, $indexMethod);
}
Creates an instance of Yiisoft\Db\Syntax\AbstractSqlParser for the given SQL expression.
| protected abstract createSqlParser( string $sql ): Yiisoft\Db\Syntax\AbstractSqlParser | ||
| $sql | string |
SQL expression to be parsed. |
| return | Yiisoft\Db\Syntax\AbstractSqlParser |
SQL parser instance. |
|---|---|---|
abstract protected function createSqlParser(string $sql): AbstractSqlParser;
| public createTable( string $table, array $columns, string|null $options = null ): string | ||
| $table | string | |
| $columns | array | |
| $options | string|null | |
public function createTable(string $table, array $columns, ?string $options = null): string
{
return $this->ddlBuilder->createTable($table, $columns, $options);
}
| public createView( string $viewName, Yiisoft\Db\Query\QueryInterface|string $subQuery ): string | ||
| $viewName | string | |
| $subQuery | Yiisoft\Db\Query\QueryInterface|string | |
public function createView(string $viewName, QueryInterface|string $subQuery): string
{
return $this->ddlBuilder->createView($viewName, $subQuery);
}
| public delete( string $table, array|string $condition, array &$params ): string | ||
| $table | string | |
| $condition | array|string | |
| $params | array | |
public function delete(string $table, array|string $condition, array &$params): string
{
return $this->dmlBuilder->delete($table, $condition, $params);
}
| public dropCheck( string $table, string $name ): string | ||
| $table | string | |
| $name | string | |
public function dropCheck(string $table, string $name): string
{
return $this->ddlBuilder->dropCheck($table, $name);
}
| public dropColumn( string $table, string $column ): string | ||
| $table | string | |
| $column | string | |
public function dropColumn(string $table, string $column): string
{
return $this->ddlBuilder->dropColumn($table, $column);
}
| public dropCommentFromColumn( string $table, string $column ): string | ||
| $table | string | |
| $column | string | |
public function dropCommentFromColumn(string $table, string $column): string
{
return $this->ddlBuilder->dropCommentFromColumn($table, $column);
}
| public dropCommentFromTable( string $table ): string | ||
| $table | string | |
public function dropCommentFromTable(string $table): string
{
return $this->ddlBuilder->dropCommentFromTable($table);
}
| public dropDefaultValue( string $table, string $name ): string | ||
| $table | string | |
| $name | string | |
public function dropDefaultValue(string $table, string $name): string
{
return $this->ddlBuilder->dropDefaultValue($table, $name);
}
| public dropForeignKey( string $table, string $name ): string | ||
| $table | string | |
| $name | string | |
public function dropForeignKey(string $table, string $name): string
{
return $this->ddlBuilder->dropForeignKey($table, $name);
}
| public dropIndex( string $table, string $name ): string | ||
| $table | string | |
| $name | string | |
public function dropIndex(string $table, string $name): string
{
return $this->ddlBuilder->dropIndex($table, $name);
}
| public dropPrimaryKey( string $table, string $name ): string | ||
| $table | string | |
| $name | string | |
public function dropPrimaryKey(string $table, string $name): string
{
return $this->ddlBuilder->dropPrimaryKey($table, $name);
}
| public dropTable( string $table, boolean $ifExists = false, boolean $cascade = false ): string | ||
| $table | string | |
| $ifExists | boolean | |
| $cascade | boolean | |
public function dropTable(string $table, bool $ifExists = false, bool $cascade = false): string
{
return $this->ddlBuilder->dropTable($table, $ifExists, $cascade);
}
| public dropUnique( string $table, string $name ): string | ||
| $table | string | |
| $name | string | |
public function dropUnique(string $table, string $name): string
{
return $this->ddlBuilder->dropUnique($table, $name);
}
| public dropView( string $viewName ): string | ||
| $viewName | string | |
public function dropView(string $viewName): string
{
return $this->ddlBuilder->dropView($viewName);
}
| public getColumnDefinitionBuilder( ): Yiisoft\Db\QueryBuilder\ColumnDefinitionBuilderInterface |
public function getColumnDefinitionBuilder(): ColumnDefinitionBuilderInterface
{
return $this->columnDefinitionBuilder;
}
| public getColumnFactory( ): Yiisoft\Db\Schema\Column\ColumnFactoryInterface |
public function getColumnFactory(): ColumnFactoryInterface
{
return $this->db->getColumnFactory();
}
| public getExpressionBuilder( Yiisoft\Db\Expression\ExpressionInterface $expression ): Yiisoft\Db\Expression\ExpressionBuilderInterface | ||
| $expression | Yiisoft\Db\Expression\ExpressionInterface | |
public function getExpressionBuilder(ExpressionInterface $expression): ExpressionBuilderInterface
{
return $this->dqlBuilder->getExpressionBuilder($expression);
}
| public getQuoter( ): Yiisoft\Db\Schema\QuoterInterface |
public function getQuoter(): QuoterInterface
{
return $this->db->getQuoter();
}
| public getServerInfo( ): Yiisoft\Db\Connection\ServerInfoInterface |
public function getServerInfo(): ServerInfoInterface
{
return $this->db->getServerInfo();
}
| public insert( string $table, array|Yiisoft\Db\Query\QueryInterface $columns, array &$params = [] ): string | ||
| $table | string | |
| $columns | array|Yiisoft\Db\Query\QueryInterface | |
| $params | array | |
public function insert(string $table, array|QueryInterface $columns, array &$params = []): string
{
return $this->dmlBuilder->insert($table, $columns, $params);
}
| public insertBatch( string $table, iterable $rows, array $columns = [], array &$params = [] ): string | ||
| $table | string | |
| $rows | iterable | |
| $columns | array | |
| $params | array | |
public function insertBatch(string $table, iterable $rows, array $columns = [], array &$params = []): string
{
return $this->dmlBuilder->insertBatch($table, $rows, $columns, $params);
}
| public insertReturningPks( string $table, array|Yiisoft\Db\Query\QueryInterface $columns, array &$params = [] ): string | ||
| $table | string | |
| $columns | array|Yiisoft\Db\Query\QueryInterface | |
| $params | array | |
public function insertReturningPks(string $table, array|QueryInterface $columns, array &$params = []): string
{
return $this->dmlBuilder->insertReturningPks($table, $columns, $params);
}
| public isTypecastingEnabled( ): boolean |
public function isTypecastingEnabled(): bool
{
return $this->dmlBuilder->isTypecastingEnabled();
}
Converts a binary value to its SQL representation using hexadecimal encoding.
| protected prepareBinary( string $binary ): string | ||
| $binary | string | |
protected function prepareBinary(string $binary): string
{
return '0x' . bin2hex($binary);
}
| public prepareParam( Yiisoft\Db\Expression\Value\Param $param ): string | ||
| $param | Yiisoft\Db\Expression\Value\Param | |
public function prepareParam(Param $param): string
{
return match ($param->type) {
DataType::BOOLEAN => $param->value ? static::TRUE_VALUE : static::FALSE_VALUE,
DataType::INTEGER => (string) (int) $param->value,
DataType::LOB => is_resource($value = $param->value)
? $this->prepareResource($value)
: $this->prepareBinary((string) $value),
DataType::NULL => 'NULL',
default => $this->prepareValue($param->value),
};
}
Converts a resource value to its SQL representation or throws an exception if conversion is not possible.
| protected prepareResource( resource $value ): string | ||
| $value | resource | |
protected function prepareResource(mixed $value): string
{
if (get_resource_type($value) !== 'stream') {
throw new InvalidArgumentException('Supported only stream resource type.');
}
/** @var string $binary */
$binary = stream_get_contents($value);
return $this->prepareBinary($binary);
}
| public prepareValue( mixed $value ): string | ||
| $value | mixed | |
public function prepareValue(mixed $value): string
{
$params = [];
/** @psalm-suppress MixedArgument */
return match (gettype($value)) {
GettypeResult::ARRAY => $this->replacePlaceholders(
$this->buildExpression(
array_is_list($value)
? new ArrayValue($value)
: new JsonValue($value),
$params,
),
array_map($this->prepareValue(...), $params),
),
GettypeResult::BOOLEAN => $value ? static::TRUE_VALUE : static::FALSE_VALUE,
GettypeResult::DOUBLE => (string) $value,
GettypeResult::INTEGER => (string) $value,
GettypeResult::NULL => 'NULL',
GettypeResult::OBJECT => match (true) {
$value instanceof Param => $this->prepareParam($value),
$value instanceof ExpressionInterface => $this->replacePlaceholders(
$this->buildExpression($value, $params),
array_map($this->prepareValue(...), $params),
),
$value instanceof StringableStream => $this->prepareBinary((string) $value),
$value instanceof BackedEnum => is_string($value->value)
? $this->db->getQuoter()->quoteValue($value->value)
: (string) $value->value,
$value instanceof Iterator && $value->key() === 0 => $this->replacePlaceholders(
$this->buildExpression(new ArrayValue($value), $params),
array_map($this->prepareValue(...), $params),
),
$value instanceof Traversable,
$value instanceof JsonSerializable => $this->replacePlaceholders(
$this->buildExpression(new JsonValue($value), $params),
array_map($this->prepareValue(...), $params),
),
default => $this->db->getQuoter()->quoteValue((string) $value),
},
GettypeResult::RESOURCE => $this->prepareResource($value),
GettypeResult::RESOURCE_CLOSED => throw new InvalidArgumentException('Resource is closed.'),
default => $this->db->getQuoter()->quoteValue((string) $value),
};
}
| public renameColumn( string $table, string $oldName, string $newName ): string | ||
| $table | string | |
| $oldName | string | |
| $newName | string | |
public function renameColumn(string $table, string $oldName, string $newName): string
{
return $this->ddlBuilder->renameColumn($table, $oldName, $newName);
}
| public renameTable( string $oldName, string $newName ): string | ||
| $oldName | string | |
| $newName | string | |
public function renameTable(string $oldName, string $newName): string
{
return $this->ddlBuilder->renameTable($oldName, $newName);
}
| public replacePlaceholders( string $sql, array $replacements ): string | ||
| $sql | string | |
| $replacements | array | |
public function replacePlaceholders(string $sql, array $replacements): string
{
if (isset($replacements[0])) {
return $sql;
}
/** @psalm-var array<string, string> $replacements */
foreach ($replacements as $placeholder => $replacement) {
if ($placeholder[0] !== ':') {
unset($replacements[$placeholder]);
$replacements[":$placeholder"] = $replacement;
}
}
$offset = 0;
$parser = $this->createSqlParser($sql);
while (null !== $placeholder = $parser->getNextPlaceholder($position)) {
if (isset($replacements[$placeholder])) {
$replacement = $replacements[$placeholder];
/** @var int $position */
$sql = substr_replace($sql, $replacement, $position + $offset, strlen($placeholder));
if (count($replacements) === 1) {
break;
}
$offset += strlen($replacement) - strlen($placeholder);
unset($replacements[$placeholder]);
}
}
return $sql;
}
| public resetSequence( string $table, integer|string|null $value = null ): string | ||
| $table | string | |
| $value | integer|string|null | |
public function resetSequence(string $table, int|string|null $value = null): string
{
return $this->dmlBuilder->resetSequence($table, $value);
}
| public selectExists( string $rawSql ): string | ||
| $rawSql | string | |
public function selectExists(string $rawSql): string
{
return $this->dqlBuilder->selectExists($rawSql);
}
| public setConditionClasses( array $classes ): void | ||
| $classes | array | |
public function setConditionClasses(array $classes): void
{
$this->dqlBuilder->setConditionClasses($classes);
}
| public setExpressionBuilders( array $builders ): void | ||
| $builders | array | |
public function setExpressionBuilders(array $builders): void
{
$this->dqlBuilder->setExpressionBuilders($builders);
}
| public setSeparator( string $separator ): void | ||
| $separator | string | |
public function setSeparator(string $separator): void
{
$this->dqlBuilder->setSeparator($separator);
}
| public truncateTable( string $table ): string | ||
| $table | string | |
public function truncateTable(string $table): string
{
return $this->ddlBuilder->truncateTable($table);
}
| public update( string $table, array $columns, array|Yiisoft\Db\Expression\ExpressionInterface|string $condition, array|Yiisoft\Db\Expression\ExpressionInterface|string|null $from = null, array &$params = [] ): string | ||
| $table | string | |
| $columns | array | |
| $condition | array|Yiisoft\Db\Expression\ExpressionInterface|string | |
| $from | array|Yiisoft\Db\Expression\ExpressionInterface|string|null | |
| $params | array | |
public function update(
string $table,
array $columns,
array|ExpressionInterface|string $condition,
array|ExpressionInterface|string|null $from = null,
array &$params = [],
): string {
return $this->dmlBuilder->update($table, $columns, $condition, $from, $params);
}
| public upsert( string $table, array|Yiisoft\Db\Query\QueryInterface $insertColumns, array|boolean $updateColumns = true, array &$params = [] ): string | ||
| $table | string | |
| $insertColumns | array|Yiisoft\Db\Query\QueryInterface | |
| $updateColumns | array|boolean | |
| $params | array | |
public function upsert(
string $table,
array|QueryInterface $insertColumns,
array|bool $updateColumns = true,
array &$params = [],
): string {
return $this->dmlBuilder->upsert($table, $insertColumns, $updateColumns, $params);
}
| public upsertReturning( string $table, array|Yiisoft\Db\Query\QueryInterface $insertColumns, array|boolean $updateColumns = true, array|null $returnColumns = null, array &$params = [] ): string | ||
| $table | string | |
| $insertColumns | array|Yiisoft\Db\Query\QueryInterface | |
| $updateColumns | array|boolean | |
| $returnColumns | array|null | |
| $params | array | |
public function upsertReturning(
string $table,
array|QueryInterface $insertColumns,
array|bool $updateColumns = true,
?array $returnColumns = null,
array &$params = [],
): string {
return $this->dmlBuilder->upsertReturning($table, $insertColumns, $updateColumns, $returnColumns, $params);
}
| public withTypecasting( boolean $typecasting = true ): Yiisoft\Db\QueryBuilder\AbstractQueryBuilder | ||
| $typecasting | boolean | |
public function withTypecasting(bool $typecasting = true): static
{
$new = clone $this;
$new->dmlBuilder = $new->dmlBuilder->withTypecasting($typecasting);
return $new;
}
Signup or Login in order to comment.