Skip to content

Commit 5a2efc5

Browse files
authored
Adapt to yiisoft/db changes (#447)
1 parent f005a58 commit 5a2efc5

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/AbstractActiveRecord.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
use Yiisoft\Db\Exception\InvalidConfigException;
1616
use Yiisoft\Db\Exception\NotSupportedException;
1717
use Yiisoft\Db\Expression\Expression;
18+
use Yiisoft\Db\Expression\ExpressionInterface;
19+
use Yiisoft\Db\Query\QueryPartsInterface;
1820

1921
use function array_diff_key;
2022
use function array_diff;
@@ -695,11 +697,11 @@ public function update(array|null $properties = null): int
695697
return $this->updateInternal($properties);
696698
}
697699

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

702-
$command->update($this->tableName(), $propertyValues, $condition, $params);
704+
$command->update($this->tableName(), $propertyValues, $condition, $from, $params);
703705

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

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

743747
$command = $this->db()->createCommand();
744-
$command->update($this->tableName(), $counters, $condition, $params);
748+
$command->update($this->tableName(), $counters, $condition, $from, $params);
745749

746750
return $command->execute();
747751
}

src/ActiveRecordInterface.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use InvalidArgumentException;
1111
use Yiisoft\Db\Exception\InvalidCallException;
1212
use Yiisoft\Db\Exception\InvalidConfigException;
13+
use Yiisoft\Db\Expression\ExpressionInterface;
1314
use Yiisoft\Db\Schema\Column\ColumnInterface;
1415

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

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

0 commit comments

Comments
 (0)