Cdbcommand & Cjson - Needs Array Of Integers


I’m having a simple SELECT query performed by CDbCommand which is directly converted to JSON using CJSON, see the code below.

Unfortunately, all the columns (including timestamp) are serialized like they’re strings, which doesn’t meet the requirements by client-side (JS) library. I’d like to avoid iterating over the results and converting the types for performance reasons.

Is there any way to force CDbCommand to return one of the values as an integer?

CJSON::encode(Yii::app()->db->createCommand("select CAST( TIMESTAMP(measure_time)*1000 as UNSIGNED) as x FROM ...")->queryAll(false));

This is how PDO works in general, so iterating over a row cannot be avoided. Database types are not cast automatically to PHP types, that’s why the CDbColumnSchema.type property exists.