Suppose I create a table and model like this.
CREATE TABLE tbl
(
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
type TINYINT UNSIGNED NOT NULL DEFAULT 1,
prefix TINYINT UNSIGNED NOT NULL DEFAULT 0,
PRIMARY KEY (id),
);
INSERT INTO tbl (id, prefix) VALUES(10, 10);
class Tbls extends ModelBase
{
protected ?int $id = null;
protected ?int $type = 1;
protected ?int $prefix = 0;
public function getId() { return $this->id; }
public function getType() { return $this->type; }
public function getPrefix() { return $this->prefix; }
}
Then get the row with id = 10.
$mdl = Tbls::findFirst(10);
At this point I haven't changed anything yet, but $mdl->getChangedFields() is ['id', 'type', 'prefix'].
After executing $mdl->assign($ary), I wanted to check if there are any changed items, but this is meaningless. Each value in the snapshot was string, but the $mdl properties are integer.
Normally, all the values obtained by PDO are obtained as character strings regardless of the table settings. So, it makes sense that the snapshot value is a string, but since the property value is an integer when it is acquired by findFirst (), it is said to be "changed". I'm in trouble.