Yii: model attributes don't save types?

I was very surprised to find that gettype($myModel->id) == 'string'for a model with an integer idin the base MySQL database.

It looks completely wrong. Does this work? If so, why? Otherwise, all ideas on how this could happen are welcome.

+3
source share
2 answers

As far as I know, Yii just assigns the values ​​received from the PDO, so probably it should be a PDO. Tbh, I really don't rely on real variable types in PHP, since it is a soft-type language, and it can be dangerous. Imo is better to call is_numeric than to check the actual type of a variable, for example.

+6
source

- Yii:

... , , PHP, .

+1

Source: https://habr.com/ru/post/1788744/


All Articles