in yii2 activerecord float,double,decimal datatype of mysql not support ! (Or I'm wrong)
when i access to this column(float,double,decimal) , yii2 return string.
how i can type casting float,double,decimal datatype of mysql to php float ?
mytable(id int, f1 float, f2 double, f3 decimal(10,2))
for example in activerecord class :
public function filters(){
// return [['f1','f2','f3'] => 'float', ...];
}
Yii returns string for unsigned integers and floating numbers. That's because typically DBMS type can represent more than PHP and we want to preserve precision.
I know nothing about Yii internals but I can answer for mysql and PDO.
First of all, for the decimal
type you cannot get anything but string, as it's the very point of this data type.
For the rest, to make PDO return int and double values with corresponding types from mysql, you have to make sure that both mysqlnd-based driver is installed and emulation mode is turned off. Given that, PDO will return you proper data types from a prepared statement.