📜  使用数组更新 - 任何代码示例

📅  最后修改于: 2022-03-11 14:58:28.028000             🧑  作者: Mango

代码示例1
/* function to build SQL UPDATE string */
function build_sql_update($table, $data, $where)
{
    $cols = array();
 
    foreach($data as $key=>$val) {
        $cols[] = "$key = '$val'";
    }
    $sql = "UPDATE $table SET " . implode(', ', $cols) . " WHERE $where";
 
    return($sql);
}