how to simplify this database update query (php)
Posted
by krike
on Stack Overflow
See other posts from Stack Overflow
or by krike
Published on 2010-04-24T13:42:05Z
Indexed on
2010/04/24
13:53 UTC
Read the original article
Hit count: 246
How could I simplify this update instruction? Whenever a client buys an item it will update the sales with 1.
$this->db->query('SELECT amount FROM shop_items WHERE itemid='.$itemid.'');
$new_amount = $item->amount+1;
if(!$this->db->query('UPDATE shop_items SET amount='.$new_amount.' WHERE itemid='.$itemid.'')):
return false;
endif;
Can't I make it more simple so there are less lines, for example:
if(!$this->db->query('UPDATE shop_items SET amount=_current_value_+1 WHERE itemid='.$itemid.'')):
return false;
endif;
is this possible? if not thanks anyway
© Stack Overflow or respective owner