Code:

$cart = Cart::findFirst(
    array(
        "carid"    => $carid,
        "carcolor" => $carcolor
    )
);
$newcart = array(
    'quantity' => intval($cartval[$i]['quantity']) + intval($quantity)
);
if($cart->update($newcart)==false){
    foreach ($cart->getMessages() as $message) {
        echo $message,"\n";
    }
    $uu['suc']="1";
    echo json_encode($uu);
}else{
    $uu['suc']="0";
    echo json_encode($uu);
}