Since php is a dynamically typed language, data types on interfaces are often cryptic.
Usually, when data is retrieved from the database, the driver does not try to convert each value to a php type that is most similar to the data type in mysql (or you can also say that php is not smart enough to do this automatically); You will have to do this conversion yourself. Fortunately, this is really easy to do:
$yourvar = (int)$yourvar;
source share