lastInsertId should be casted to column type

Dear all,

The official documentation for PDO state that the lastInsertId method return a string : string PDO::lastInsertId ([ string $name = NULL ] )

Thus after inserting new data into the DB, the primary key field is always a string, which causes trouble when using that record afterwards (ie : json converssion will use quotes when they it not)

Would it be possible to cast the result of the function back to the type specified in the database schema ?

Replying to myself here, I ended up doing it manually form my own code. Too bad this did not get any attention.

It was too bad that you didn’t create a ticket for it at the Yii issue tracker. :)

This was already discussed. The reason is, that PHP int range does not cover all possible int values from some DBs. Thus strings are used instead.