旧的查询更新现有列是这样MySQL的:使用该列的值在准备好的查询
update tbl_order set `pack_id` =0, `pack_down_count`=pack_down_count + '".intval($_POST['item_number'])."',`price`='".$_POST['mc_gross']."', `otime`=Now(), `ptime`=Now(), status='paid', pack_download=pack_download + '".intval($_POST['item_number'])."' where member_id='".$_MYVAR['userid']."'"
我喜欢它,我使用的是类从https://github.com/joshcam/PHP-MySQLi-Database-Class
更改为准备statment更新
我改变上述查询,以
$data = array(
'pack_id' =>$_MYVAR['pack_id'],
'pack_apply_count' =>`pack_apply_count` + intval($_POST['item_number']),
'price' =>$_POST['mc_gross'],
'otime' =>date('Y-m-d H:i:s'),
'ptime' =>date('Y-m-d H:i:s'),
'status' =>'paid',
'pack_apply' =>`pack_apply` + intval($_POST['item_number'])
);
$db->where('member_id',$_MYVAR['userid']);
$db->update("tbl_order",$data);
也三ED周围没有pack_apply_count和pack_apply反向引号,但没有更新我的表
$data = array(
'pack_id' =>$_MYVAR['pack_id'],
'pack_apply_count' =>pack_apply_count + intval($_POST['item_number']),
'price' =>$_POST['mc_gross'],
'otime' =>date('Y-m-d H:i:s'),
'ptime' =>date('Y-m-d H:i:s'),
'status' =>'paid',
'pack_apply' =>pack_apply + intval($_POST['item_number'])
);
$db->where('member_id',$_MYVAR['userid']);
$db->update("tbl_order",$data);
请告诉正确的方法来更新表
答案:$ DB-> INC(pack_apply)和$ DB-> INC那里(pack_apply_count) –