/**
* 组合批量更新sql 方法
* @param string $updata 需要更新的数据
* @param string $table 表名
* @param string $colnum 要更新的字段名
* @param string $whereColnum 条件字段
* @author jackbon<[email protected]>
* @return string
*/
function updateSql($updata,$table,$colnum,$whereColnum)
{
$zhong = '';
foreach ($updata as $value)
{
$zhong .= "WHEN {$value['id']} THEN '{$value['title']}' ";
$ids[] = $value['id'];
}
$ids = implode(',',$ids);
$sql = "UPDATE {$table} SET {$colnum} = CASE {$whereColnum} {$zhong} END WHERE {$whereColnum} IN ({$ids})";
return $sql;
}