Answer the question
In order to leave comments, you need to log in
Why does Yii return a string instead of an integer?
Hello!
Faced such a situation, some int fields are converted to string for reasons that are not clear to me.
In the database, the table fields are in integer, in the model also in the validation rules integer, and I do var_dump and there the situation is approximately as follows:
'id' => string '1' (length=1)
'name' => string 'Test' (length=4)
'route_id' => string '1' (length=1)
'price' => string '2400' (length=4)
'seats' => int 45
'status' => int 1
Answer the question
In order to leave comments, you need to log in
Maybe the salt is that there is no strict typing in PHP?
There are a lot of options where it can become a string, but this does not affect the work in any way (should not)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question