I need to set the column alias to a number. This works, but the other columns in the select are now a string … is it possible to set only one column?
->setTypeMap([
'reservation_stock' => 'integer',
])
I need to set the column alias to a number. This works, but the other columns in the select are now a string … is it possible to set only one column?
->setTypeMap([
'reservation_stock' => 'integer',
])
There’s no convenience query method (yet) to add types to a possibly existing type map, currently you’d have to get the current typemap and add to it, eg you can’t do it in a chained manner:
$query->getTypeMap()->addDefaults([
'reservation_stock' => 'integer',
]);
Also note that unless you want this to affect all operations, for example also binding values, you should use the select type map instead, which only affects the selected fields:
$query->getSelectTypeMap()->addDefaults([
'reservation_stock' => 'integer',
]);
Thank you and how do I use it in querybuilder, please?
'GoodsItems' => [
'queryBuilder' => function (Query $q) {
......................
I already have it, it works, thank you
'queryBuilder' => function (Query $q) {
$q->getSelectTypeMap()->addDefaults([
'reservation_stock' => 'integer',
]);
return $q
->select([