一、代码
/** * 拼接sql语句 * @param $table * @param $array * @return string */ function insertSql($table, $array) { $sqlk = ''; $sqlv = ''; foreach ($array as $k => $v) { $sqlk .= ',' . $k; $sqlv .= ",'$v'"; } $sqlk = substr($sqlk, 1); $sqlv = substr($sqlv, 1); $sql = "insert into $table ($sqlk) values ($sqlv)"; return $sql; }
标签:sqlv,拼接,sqlk,sql,table,array,PHP From: https://www.cnblogs.com/yang-2018/p/16899184.html