如何使用cakephp在mysql中插入multiple selectbox的值
我是cakePHP新手,尝试在mysql中存储multiple select box的值 我的控制器文件是:-如何使用cakephp在mysql中插入multiple selectbox的值,php,mysql,cakephp,Php,Mysql,Cakephp,我是cakePHP新手,尝试在mysql中存储multiple select box的值 我的控制器文件是:- $this->model_name->save($this->request->data); $this->request->data中的值为:- array( [model_name] = array( ['field_name'] = array( [0] => 'A', [1] => 'B' ) ) ); 我
$this->model_name->save($this->request->data);
$this->request->data中的值为:-
array(
[model_name] = array(
['field_name'] = array(
[0] => 'A',
[1] => 'B'
)
)
);
我使用的字段名与数据库中存储的列名相同
告诉我如何解决此问题。尝试使用saveMany()
-
$this->model_name->saveMany($this->request->data);
试试这样的
$options = array('1' => 'Liverpool', '2' => 'Manchester');
echo $this->Form->input('Locations', array(
'multiple' => 'multiple',
'type' => 'select',
'options' => $options
));
你的桌子是什么样子的?如果要在一行中保存多个数据,可以使用
json\u encode将其另存为json
saveMany()
用于同一行的多行model@LucasVieira这与我认为的情况相同。@sgt在他的例子中,我理解一个字段的多个数据,但他可能不够清楚