我有这个代码:
function insertGenre() {
$genres = explode(',',$this->input->post('genreName'));
foreach($genres as $genre) {
$temp = array(
'id' => null,
'name' => $genre,
'popular' => '0'
);
$data2[] = $temp;
}
return $data2;
$data = array(
'id' => null,
'name' => $this->input->post('genreName'),
'popular' => '0'
);
//$this->db->insert('genres',$data);
$this->db->insert_batch('genres',$data2);
}
它应该运行得很好(我在这里遇到了几个问题),但事实并非如此。我究竟做错了什么?