Hello,
foreach($items as $item)
{
$id = $item['id'];
$qty = $item['qty'];
$product = Product::model()->findBySql('select Item, On_hand_qty from shopinventory where Item =:p1',array(':p1'=>$id));
$dbqty = $product->On_hand_qty - $qty;
$product->On_hand_qty = $dbqty;
$product->save();
}
My primate key is character.
Is there a cleaner way to update a record?
Thanks