phpcms处理:
public function insert($data, $table, $return_insert_id = false, $replace = false) {
if(!is_array( $data ) || $table == '' || count($data) == 0) {
return false;
}
$fielddata = array_keys($data); //返回键名的集合
$valuedata = array_values($data);// 返回键值的数组
array_walk($fielddata, array($this, 'add_special_char'));
array_walk($valuedata, array($this, 'escape_string'));
$field = implode (',', $fielddata);
$value = implode (',', $valuedata);
$cmd = $replace ? 'REPLACE INTO' : 'INSERT INTO';
$sql = $cmd.' `'.$this->config['database'].'`.`'.$table.'`('.$field.') VALUES ('.$value.')';
$return = $this->execute($sql);
return $return_insert_id ? $this->insert_id() : $return;
}
自己处理办法:
public function addVotedata($insertRows)
{
$columns='';
$vals='';
foreach($insertRows as $id=>$value){
$columns.=$id.',';
$vals.="'".$value."',";
}
$columns=rtrim($columns,',');
$vals=rtrim($vals,',');
$query = $this->db->query("insert into ".$this->table_data."(".$columns.") values (".$vals.")");
return($query);
}