更新时间:2022-12-11 20:27:45
我只是在这里看到问题。
我看到 datastring
变量是一个字符串,每个值都用,
分隔在您的控制器上发布吧?
因此,它将是您控制器上的 $ _ POST ['data']
。
I just see the issue here.
I see that datastring
variable is an string that each value is separated by ,
that you just use to post on your controller right?
So it will be $_POST['data']
on your controller.
然后尝试在控制器上使用 explode()
:
Then try to use explode()
like this on your controller:
$ parseddata = explode(',',$ _ POST ['data']);
$parseddata = explode(',',$_POST['data']);
让我们继续您的代码:
public function insertNewRole(){
$parseddata = explode(',',$_POST['data']);
$basic_data = array();
$basic_data = array(
'accs_trans_sec' => $parseddata[0], //The value should be 1
'accs_acctng_sec' => $parseddata[1],//The value should be 0
'accs_admin_sec' => $parseddata[2], //The value should be 1
'accs_dashboard_sec' => $parseddata[3], //The value should be 0
'accs_reports_sec' => $parseddata[4] //The value should be 1
);
$result = $this->RoleModel->saveRole($basic_data);
if($result == true){
echo ("Successfully inserted!");
}else{
echo ("Problem!");
}
}
让我们看看您是否可以解决这个问题。
Let's see if you can get through this.
编辑:根据您之前的帖子,您的模型上有一个循环,我对其进行了修改,并且应该这样:
Based on your previous post, your model has a loop on it, I modify it and should like this:
public function saveRole($basic_data)
{
$this->db->insert('roles_global_access', $basic_data);
return ($this->db->affected_rows() != 1) ? false : true;
}