我有一个需要向许多朋友发送消息的网络应用程序。但是我遇到了一个错误..请帮助我....
下面是我的控制器
public function message(){
$this->form_validation->set_rules('message','Message', 'required');
$this->form_validation->set_rules('friend_id[]','Recipients', 'required');
if($this->form_validation->run()){
$data = $this->input->post("friend_id[]");
unset($data['submit']);
$this->load->model('Queries');
$message=$this->Queries->saveMessage();
if($message){
echo "Success";
}else{
echo "error";
}
}
else{
echo validation_errors();
}
}
这是我的模特
public function saveMessage($data){
$i=0;
foreach($data['friend_id'] as $friend_id){
$record = array(
'friend_id' => $friend_id,
'message' => $data['message']
);
$this->db->insert('tbl_messages', $record);
$i++;
}
return $data;
}
当我运行它时..它显示错误并且数据库中没有插入数据