[英]How to insert value of multiple selectbox in mysql using cakephp
I'm new to cakePHP and try to store the value of multiple select box in mysql 我是CakePHP的新手,并尝试将多个选择框的值存储在mysql中
My controller file is:- 我的控制器文件是:
$this->model_name->save($this->request->data);
Value coming in $this->request->data is:- $ this-> request-> data中的值是:-
array(
[model_name] = array(
['field_name'] = array(
[0] => 'A',
[1] => 'B'
)
)
);
I'm using the same field name as column name stored in database. 我使用的字段名称与存储在数据库中的列名称相同。
Tell me how to resolve this problem. 告诉我如何解决此问题。
尝试使用saveMany()
-
$this->model_name->saveMany($this->request->data);
Try something like this. 尝试这样的事情。
$options = array('1' => 'Liverpool', '2' => 'Manchester');
echo $this->Form->input('Locations', array(
'multiple' => 'multiple',
'type' => 'select',
'options' => $options
));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.