function array_to_sql($array, $type='insert', $exclude = array()){
$sql = '';
if(count($array) > 0){
foreach ($exclude as $exkey) {
unset($array[$exkey]);//剔除不要的key
}
if('insert' == $type){
$keys = array_keys($array);
$values = array_values($array);
$col = implode("`, `", $keys);
$val = implode("', '", $values);
$sql = "(`$col`) values('$val')";
}else if('update' == $type){
$tempsql = '';
$temparr = array();
foreach ($array as $key => $value) {
$tempsql = "'$key' = '$value'";
$temparr[] = $tempsql;
}
$sql = implode(",", $temparr);
}
}
return $sql;
}