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 {@see QueryInterface} object.
SQL statements are created from {@see \Yiisoft\Db\Query\QueryInterface} objects using the {@see \Yiisoft\Db\QueryBuilder\AbstractDQLQueryBuilder::build()}-method.
AbstractQueryBuilder is also used by {@see \Yiisoft\Db\Command\CommandInterface} to build SQL statements such as {@see \Yiisoft\Db\QueryBuilder\insert()}, {@see \Yiisoft\Db\QueryBuilder\update()}, {@see \Yiisoft\Db\QueryBuilder\delete()} and {@see \Yiisoft\Db\QueryBuilder\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 {@see 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 mixed __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 ) | ||
| $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 string addCheck ( string $table, string $name, string $expression ) | ||
| $table | string | |
| $name | string | |
| $expression | string | |
public function addCheck(string $table, string $name, string $expression): string
{
return $this->ddlBuilder->addCheck($table, $name, $expression);
}
| public string addColumn ( string $table, string $column, Yiisoft\Db\Schema\Column\ColumnInterface|string $type ) | ||
| $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 string addCommentOnColumn ( string $table, string $column, string $comment ) | ||
| $table | string | |
| $column | string | |
| $comment | string | |
public function addCommentOnColumn(string $table, string $column, string $comment): string
{
return $this->ddlBuilder->addCommentOnColumn($table, $column, $comment);
}
| public string addCommentOnTable ( string $table, string $comment ) | ||
| $table | string | |
| $comment | string | |
public function addCommentOnTable(string $table, string $comment): string
{
return $this->ddlBuilder->addCommentOnTable($table, $comment);
}
| public string addDefaultValue ( string $table, string $name, string $column, mixed $value ) | ||
| $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 string addForeignKey ( string $table, string $name, array|string $columns, string $referenceTable, array|string $referenceColumns, ?string $delete = null, ?string $update = null ) | ||
| $table | string | |
| $name | string | |
| $columns | array|string | |
| $referenceTable | string | |
| $referenceColumns | array|string | |
| $delete | ?string | |
| $update | ?string | |
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 string addPrimaryKey ( string $table, string $name, array|string $columns ) | ||
| $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 string addUnique ( string $table, string $name, array|string $columns ) | ||
| $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 string alterColumn ( string $table, string $column, Yiisoft\Db\Schema\Column\ColumnInterface|string $type ) | ||
| $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 string bindParam ( mixed $value, array &$params = [] ) | ||
| $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 array build ( Yiisoft\Db\Query\QueryInterface $query, array $params = [] ) | ||
| $query | Yiisoft\Db\Query\QueryInterface | |
| $params | array | |
public function build(QueryInterface $query, array $params = []): array
{
return $this->dqlBuilder->build($query, $params);
}
| public string buildColumnDefinition ( Yiisoft\Db\Schema\Column\ColumnInterface|string $column ) | ||
| $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 string buildColumns ( array|string $columns ) | ||
| $columns | array|string | |
public function buildColumns(array|string $columns): string
{
return $this->dqlBuilder->buildColumns($columns);
}
| public string buildCondition ( array|string|Yiisoft\Db\Expression\ExpressionInterface|null $condition, array &$params = [] ) | ||
| $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 string buildExpression ( Yiisoft\Db\Expression\ExpressionInterface $expression, array &$params = [] ) | ||
| $expression | Yiisoft\Db\Expression\ExpressionInterface | |
| $params | array | |
public function buildExpression(ExpressionInterface $expression, array &$params = []): string
{
return $this->dqlBuilder->buildExpression($expression, $params);
}
| public string buildFor ( array $values ) | ||
| $values | array | |
public function buildFor(array $values): string
{
return $this->dqlBuilder->buildFor($values);
}
| public string buildFrom ( array $tables, array &$params ) | ||
| $tables | array | |
| $params | array | |
public function buildFrom(array $tables, array &$params): string
{
return $this->dqlBuilder->buildFrom($tables, $params);
}
| public string buildGroupBy ( array $columns, array &$params = [] ) | ||
| $columns | array | |
| $params | array | |
public function buildGroupBy(array $columns, array &$params = []): string
{
return $this->dqlBuilder->buildGroupBy($columns, $params);
}
| public string buildHaving ( array|Yiisoft\Db\Expression\ExpressionInterface|string|null $condition, array &$params = [] ) | ||
| $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 string buildJoin ( array $joins, array &$params ) | ||
| $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 string buildOrderBy ( array $columns, array &$params = [] ) | ||
| $columns | array | |
| $params | array | |
public function buildOrderBy(array $columns, array &$params = []): string
{
return $this->dqlBuilder->buildOrderBy($columns, $params);
}
| public string buildOrderByAndLimit ( string $sql, array $orderBy, Yiisoft\Db\Expression\ExpressionInterface|integer|null $limit, Yiisoft\Db\Expression\ExpressionInterface|integer|null $offset, array &$params = [] ) | ||
| $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 string buildSelect ( array $columns, array &$params, boolean $distinct = false, ?string $selectOption = null ) | ||
| $columns | array | |
| $params | array | |
| $distinct | boolean | |
| $selectOption | ?string | |
public function buildSelect(
array $columns,
array &$params,
bool $distinct = false,
?string $selectOption = null,
): string {
return $this->dqlBuilder->buildSelect($columns, $params, $distinct, $selectOption);
}
| public string buildUnion ( array $unions, array &$params ) | ||
| $unions | array | |
| $params | array | |
public function buildUnion(array $unions, array &$params): string
{
return $this->dqlBuilder->buildUnion($unions, $params);
}
| public string buildValue ( mixed $value, array &$params ) | ||
| $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 string buildWhere ( array|string|Yiisoft\Db\QueryBuilder\Condition\ConditionInterface|Yiisoft\Db\Expression\ExpressionInterface|null $condition, array &$params = [] ) | ||
| $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 string buildWithQueries ( array $withQueries, array &$params ) | ||
| $withQueries | array | |
| $params | array | |
public function buildWithQueries(array $withQueries, array &$params): string
{
return $this->dqlBuilder->buildWithQueries($withQueries, $params);
}
| public string checkIntegrity ( string $schema = '', string $table = '', boolean $check = true ) | ||
| $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 Yiisoft\Db\QueryBuilder\Condition\ConditionInterface createConditionFromArray ( array $condition ) | ||
| $condition | array | |
public function createConditionFromArray(array $condition): ConditionInterface
{
return $this->dqlBuilder->createConditionFromArray($condition);
}
| public string createIndex ( string $table, string $name, array|string $columns, ?string $indexType = null, ?string $indexMethod = null ) | ||
| $table | string | |
| $name | string | |
| $columns | array|string | |
| $indexType | ?string | |
| $indexMethod | ?string | |
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 {@see AbstractSqlParser} for the given SQL expression.
| protected abstract Yiisoft\Db\Syntax\AbstractSqlParser createSqlParser ( string $sql ) | ||
| $sql | string |
SQL expression to be parsed. |
| return | Yiisoft\Db\Syntax\AbstractSqlParser |
SQL parser instance. |
|---|---|---|
abstract protected function createSqlParser(string $sql): AbstractSqlParser;
| public string createTable ( string $table, array $columns, ?string $options = null ) | ||
| $table | string | |
| $columns | array | |
| $options | ?string | |
public function createTable(string $table, array $columns, ?string $options = null): string
{
return $this->ddlBuilder->createTable($table, $columns, $options);
}
| public string createView ( string $viewName, Yiisoft\Db\Query\QueryInterface|string $subQuery ) | ||
| $viewName | string | |
| $subQuery | Yiisoft\Db\Query\QueryInterface|string | |
public function createView(string $viewName, QueryInterface|string $subQuery): string
{
return $this->ddlBuilder->createView($viewName, $subQuery);
}
| public string delete ( string $table, array|string $condition, array &$params ) | ||
| $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 string dropCheck ( string $table, string $name ) | ||
| $table | string | |
| $name | string | |
public function dropCheck(string $table, string $name): string
{
return $this->ddlBuilder->dropCheck($table, $name);
}
| public string dropColumn ( string $table, string $column ) | ||
| $table | string | |
| $column | string | |
public function dropColumn(string $table, string $column): string
{
return $this->ddlBuilder->dropColumn($table, $column);
}
| public string dropCommentFromColumn ( string $table, string $column ) | ||
| $table | string | |
| $column | string | |
public function dropCommentFromColumn(string $table, string $column): string
{
return $this->ddlBuilder->dropCommentFromColumn($table, $column);
}
| public string dropCommentFromTable ( string $table ) | ||
| $table | string | |
public function dropCommentFromTable(string $table): string
{
return $this->ddlBuilder->dropCommentFromTable($table);
}
| public string dropDefaultValue ( string $table, string $name ) | ||
| $table | string | |
| $name | string | |
public function dropDefaultValue(string $table, string $name): string
{
return $this->ddlBuilder->dropDefaultValue($table, $name);
}
| public string dropForeignKey ( string $table, string $name ) | ||
| $table | string | |
| $name | string | |
public function dropForeignKey(string $table, string $name): string
{
return $this->ddlBuilder->dropForeignKey($table, $name);
}
| public string dropIndex ( string $table, string $name ) | ||
| $table | string | |
| $name | string | |
public function dropIndex(string $table, string $name): string
{
return $this->ddlBuilder->dropIndex($table, $name);
}
| public string dropPrimaryKey ( string $table, string $name ) | ||
| $table | string | |
| $name | string | |
public function dropPrimaryKey(string $table, string $name): string
{
return $this->ddlBuilder->dropPrimaryKey($table, $name);
}
| public string dropTable ( string $table, boolean $ifExists = false, boolean $cascade = false ) | ||
| $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 string dropUnique ( string $table, string $name ) | ||
| $table | string | |
| $name | string | |
public function dropUnique(string $table, string $name): string
{
return $this->ddlBuilder->dropUnique($table, $name);
}
| public string dropView ( string $viewName ) | ||
| $viewName | string | |
public function dropView(string $viewName): string
{
return $this->ddlBuilder->dropView($viewName);
}
| public Yiisoft\Db\QueryBuilder\ColumnDefinitionBuilderInterface getColumnDefinitionBuilder ( ) |
public function getColumnDefinitionBuilder(): ColumnDefinitionBuilderInterface
{
return $this->columnDefinitionBuilder;
}
| public Yiisoft\Db\Schema\Column\ColumnFactoryInterface getColumnFactory ( ) |
public function getColumnFactory(): ColumnFactoryInterface
{
return $this->db->getColumnFactory();
}
| public Yiisoft\Db\Expression\ExpressionBuilderInterface getExpressionBuilder ( Yiisoft\Db\Expression\ExpressionInterface $expression ) | ||
| $expression | Yiisoft\Db\Expression\ExpressionInterface | |
public function getExpressionBuilder(ExpressionInterface $expression): ExpressionBuilderInterface
{
return $this->dqlBuilder->getExpressionBuilder($expression);
}
| public Yiisoft\Db\Schema\QuoterInterface getQuoter ( ) |
public function getQuoter(): QuoterInterface
{
return $this->db->getQuoter();
}
| public Yiisoft\Db\Connection\ServerInfoInterface getServerInfo ( ) |
public function getServerInfo(): ServerInfoInterface
{
return $this->db->getServerInfo();
}
| public string insert ( string $table, array|Yiisoft\Db\Query\QueryInterface $columns, array &$params = [] ) | ||
| $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 string insertBatch ( string $table, iterable $rows, array $columns = [], array &$params = [] ) | ||
| $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 string insertReturningPks ( string $table, array|Yiisoft\Db\Query\QueryInterface $columns, array &$params = [] ) | ||
| $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 boolean isTypecastingEnabled ( ) |
public function isTypecastingEnabled(): bool
{
return $this->dmlBuilder->isTypecastingEnabled();
}
Converts a binary value to its SQL representation using hexadecimal encoding.
| protected string prepareBinary ( string $binary ) | ||
| $binary | string | |
protected function prepareBinary(string $binary): string
{
return '0x' . bin2hex($binary);
}
| public string prepareParam ( Yiisoft\Db\Expression\Value\Param $param ) | ||
| $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 string prepareResource ( resource $value ) | ||
| $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 string prepareValue ( mixed $value ) | ||
| $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 string renameColumn ( string $table, string $oldName, string $newName ) | ||
| $table | string | |
| $oldName | string | |
| $newName | string | |
public function renameColumn(string $table, string $oldName, string $newName): string
{
return $this->ddlBuilder->renameColumn($table, $oldName, $newName);
}
| public string renameTable ( string $oldName, string $newName ) | ||
| $oldName | string | |
| $newName | string | |
public function renameTable(string $oldName, string $newName): string
{
return $this->ddlBuilder->renameTable($oldName, $newName);
}
| public string replacePlaceholders ( string $sql, array $replacements ) | ||
| $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 string resetSequence ( string $table, integer|string|null $value = null ) | ||
| $table | string | |
| $value | integer|string|null | |
public function resetSequence(string $table, int|string|null $value = null): string
{
return $this->dmlBuilder->resetSequence($table, $value);
}
| public string selectExists ( string $rawSql ) | ||
| $rawSql | string | |
public function selectExists(string $rawSql): string
{
return $this->dqlBuilder->selectExists($rawSql);
}
| public void setConditionClasses ( array $classes ) | ||
| $classes | array | |
public function setConditionClasses(array $classes): void
{
$this->dqlBuilder->setConditionClasses($classes);
}
| public void setExpressionBuilders ( array $builders ) | ||
| $builders | array | |
public function setExpressionBuilders(array $builders): void
{
$this->dqlBuilder->setExpressionBuilders($builders);
}
| public void setSeparator ( string $separator ) | ||
| $separator | string | |
public function setSeparator(string $separator): void
{
$this->dqlBuilder->setSeparator($separator);
}
| public string truncateTable ( string $table ) | ||
| $table | string | |
public function truncateTable(string $table): string
{
return $this->ddlBuilder->truncateTable($table);
}
| public string update ( string $table, array $columns, array|Yiisoft\Db\Expression\ExpressionInterface|string $condition, array|Yiisoft\Db\Expression\ExpressionInterface|string|null $from = null, array &$params = [] ) | ||
| $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 string upsert ( string $table, array|Yiisoft\Db\Query\QueryInterface $insertColumns, array|boolean $updateColumns = true, array &$params = [] ) | ||
| $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 string upsertReturning ( string $table, array|Yiisoft\Db\Query\QueryInterface $insertColumns, array|boolean $updateColumns = true, ?array $returnColumns = null, array &$params = [] ) | ||
| $table | string | |
| $insertColumns | array|Yiisoft\Db\Query\QueryInterface | |
| $updateColumns | array|boolean | |
| $returnColumns | ?array | |
| $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 static withTypecasting ( boolean $typecasting = true ) | ||
| $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.