There is an ip property (in the database). Recording is normal. When reading INET_NTOA, Yii truncates the IP to the first point. Displays for example 192, but should 192.168.225.1. When fetching asArray (), everything works fine.
Also, if you create a new property like public $ip_string and select … as ip_string, it displays normally
Where is the bug?
And it will return a string of '3232293121' as the ip column value, which will be converted into an integer of 3232293121 when the ActiveRecord model is populated with the query result. It’s natural that a string of '192.168.225.1' is converted into an integer of 192.
Note that asArray() preserves the query result as a string, without converting it to the data type of the column. Check the following section of the guide.
The data type of ip is determined as integer implicitly down in the base model of ActiveRecord by referring to the table scheme and I think it’s not a good idea to re-define it as a string. So what we could do would be defining another attribute ip_string as you are doing.
I would leave ip as it is, and would not try to let it return the ip address string.