Skip to content
Merged
12 changes: 8 additions & 4 deletions src/AbstractActiveRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
use Yiisoft\Db\Exception\InvalidConfigException;
use Yiisoft\Db\Exception\NotSupportedException;
use Yiisoft\Db\Expression\Expression;
use Yiisoft\Db\Expression\ExpressionInterface;
use Yiisoft\Db\Query\QueryPartsInterface;

use function array_diff_key;
use function array_diff;
Expand Down Expand Up @@ -695,11 +697,11 @@ public function update(array|null $properties = null): int
return $this->updateInternal($properties);
}

public function updateAll(array $propertyValues, array|string $condition = [], array $params = []): int
public function updateAll(array $propertyValues, array|string $condition = [], array|ExpressionInterface|string|null $from = null, array $params = []): int
{
$command = $this->db()->createCommand();

$command->update($this->tableName(), $propertyValues, $condition, $params);
$command->update($this->tableName(), $propertyValues, $condition, $from, $params);

return $command->execute();
}
Expand All @@ -720,6 +722,8 @@ public function updateAll(array $propertyValues, array|string $condition = [], a
* Use negative values if you want to decrement the counters.
* @param array|string $condition The conditions that will be put in the `WHERE` part of the `UPDATE` SQL.
* Please refer to {@see Query::where()} on how to specify this parameter.
* @param array|ExpressionInterface|string|null $from The FROM part of the `UPDATE` SQL.
* Please refer to {@see QueryPartsInterface::from()} on how to specify this parameter.
* @param array $params The parameters (name => value) to be bound to the query.
*
* Do not name the parameters as `:bp0`, `:bp1`, etc., because they are used internally by this method.
Expand All @@ -730,7 +734,7 @@ public function updateAll(array $propertyValues, array|string $condition = [], a
*
* @return int The number of rows updated.
*/
public function updateAllCounters(array $counters, array|string $condition = '', array $params = []): int
public function updateAllCounters(array $counters, array|string $condition = '', array|ExpressionInterface|string|null $from = null, array $params = []): int
{
$n = 0;

Expand All @@ -741,7 +745,7 @@ public function updateAllCounters(array $counters, array|string $condition = '',
}

$command = $this->db()->createCommand();
$command->update($this->tableName(), $counters, $condition, $params);
$command->update($this->tableName(), $counters, $condition, $from, $params);

return $command->execute();
}
Expand Down
5 changes: 4 additions & 1 deletion src/ActiveRecordInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use InvalidArgumentException;
use Yiisoft\Db\Exception\InvalidCallException;
use Yiisoft\Db\Exception\InvalidConfigException;
use Yiisoft\Db\Expression\ExpressionInterface;
use Yiisoft\Db\Schema\Column\ColumnInterface;

/**
Expand Down Expand Up @@ -503,6 +504,8 @@ public function update(array|null $properties = null): int;
* @param array $propertyValues Property values (name-value pairs) to be saved into the table.
* @param array|string $condition The conditions that will be put in the `WHERE` part of the `UPDATE` SQL.
* Please refer to {@see Query::where()} on how to specify this parameter.
* @param array|ExpressionInterface|string|null $from The FROM part of the `UPDATE` SQL.
* Please refer to {@see QueryPartsInterface::from()} on how to specify this parameter.
* @param array $params The parameters (name => value) to be bound to the query.
*
* @throws InvalidConfigException
Expand All @@ -511,7 +514,7 @@ public function update(array|null $properties = null): int;
*
* @return int The number of rows updated.
*/
public function updateAll(array $propertyValues, array|string $condition = [], array $params = []): int;
public function updateAll(array $propertyValues, array|string $condition = [], array|ExpressionInterface|string|null $from = null, array $params = []): int;

/**
* Insert a row into the associated database table if the record doesn't already exist (matching unique constraints)
Expand Down
Loading