一、代码
/**
* 拼接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;
}