日期:2014-05-16 浏览次数:20435 次
$arr = array ( 0 => array ( 'id' => 42 ) ,1 => array ( 'id' => 49 ), 2 => array ( 'id' => 50 ), 3 => array ( 'id' => 51 ), 4 => array ( 'id' => 52 ) );
foreach ($arr as $key => $value) {
$sql = "update tableName set count = count + ".($key+1)." where id = ".$value['id'];
mysql_query($sql);
}
$ar = array ( 0 => array ( 'id' => 42 ) ,1 => array ( 'id' => 49 ), 2 => array ( 'id' => 50 ), 3 => array ( 'id' => 51 ), 4 => array ( 'id' => 52 ) );
$s = join(',', array_map('current', $ar));
$sql = "update tbl_name set count=count+find_inset(id,'$s')";
mysql_query($sql);