in my table, I have a decimal field of quantity. The value of 'quantity' in the database is 1.00 but when I selecting it from query, it is giving me integer 1. However, if the value will 1.25, it gives the same float value 1.25. Here is my query and output -
Query
$app_cart = $this->AppCart->find()->select(['AppCart.id','item'=>'Items.name','price'=>'Items.sales_rate','quantity'=>'AppCart.quantity'])
->where(['AppCart.user_id'=>1])->contain(['Items']);
Output
{
"success": true,
"message": "List Found",
"app_cart": [
{
"id": 4,
"item": "KANGAN SAREE",
"price": 1375,
"quantity": 1
},
{
"id": 5,
"item": "KANGAN SAREE",
"price": 1375,
"quantity": 1
}
]}
I have tried
$app_cart
->selectTypeMap()
->addDefaults([
'quantity' => 'decimal'
]);