When you have a MySQL database connection set to STRICT_TRANS_TABLE, the
database server won't accept the PHP true/false value, it refuses it with the
following error: "SQLSTATE[HY000]: General error: 1366 Incorrect integer value:
'' for column 'xy' at row 1".
The error originates from that PHP tries to pass the boolean value as a
PHP-boolean, but in MySQL such value doesn't exist. So it's necessary to simple
cast it to integer.
In the mapper's toArray() function (~56. line) I replaced the following:
'<?=$column['field']?>' => $model->get<?=$column['capital']?>(),
to:
<?php $typeCast = $column['phptype'] == 'boolean' ? ' (int)' : '';?>
'<?=$column['field']?>' =><?=$typeCast?> $model->get<?=$column['capital']?>(),
This patch works fine, but it doesn't handle other DB engines or when you need
boolean values in PHP code (aka. you need the toArray() function not for save
into the database).
Original issue reported on code.google.com by szots...@gmail.com on 20 Aug 2012 at 10:33
Original issue reported on code.google.com by
szots...@gmail.com
on 20 Aug 2012 at 10:33