V
V
Vladimir2017-03-10 16:09:32
Yii
Vladimir, 2017-03-10 16:09:32

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

moreover, all these fields in my database and in the model are integer, except for name, and I get some in int, some in string
Who faced this and what is the salt, where to dig?
I found that the question was raised here , but it seems like it’s already closed, but in this case I don’t get an array using asArray ()

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Deniska Petrov, 2017-03-10
@ipdesign

Try
www.yiiframework.com/doc-2.0/yii-behaviors-attribu...

A
Alexander Aksentiev, 2017-03-10
@Sanasol

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 question

Ask a Question

731 491 924 answers to any question