You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Will result in a query:
UPDATE item SET id = 2 WHERE id = 2;
Assuming that ID 2 not exists for this example, the query would affect 0 rows.
in model->doUpdate() the buildPkeyCriteria() method is used to create the selectCriteria, it builds a selection criteria based on $this->id as the value, but $this->id is already set to the new value by setPrimaryKey(), resulting in a WHERE clause containing the new ID, where the old ID would be needed.
The text was updated successfully, but these errors were encountered:
Using the following schema as example:
Note that for the PK autoIncrement is not set.
When trying to change a primary key:
$item = ItemQuery::create()->findPK(1);
$item->setPrimaryKey(2);
$item->save();
Will result in a query:
UPDATE item SET id = 2 WHERE id = 2;
Assuming that ID 2 not exists for this example, the query would affect 0 rows.
in model->doUpdate() the buildPkeyCriteria() method is used to create the selectCriteria, it builds a selection criteria based on $this->id as the value, but $this->id is already set to the new value by setPrimaryKey(), resulting in a WHERE clause containing the new ID, where the old ID would be needed.
The text was updated successfully, but these errors were encountered: