Set PDO::ATTR_EMULATE_PREPARES
to false, if you really need it with loosely-typed PHP
If mysql_fetch_row
returns you int for SUM either (I never cared to check) - then it does some magic like if (ctype_digit($val)) $row[$key] = (int)$val;
- so you can do in your DBAL
As far as I understand the way prepared statements works, it uses the same packet structure for either sending and retrieving data, and this packet contains data type.
It looks like that server can return data in 2 formats - native and mysqlnd, depends on the request type. A latter one can be interpreted by client library to cast resulting value.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…