简体   繁体   English

如何使用cakephp在mysql中插入多个selectbox的值

[英]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.

相关问题 如何显示在CakePHP选择框中选择的选择值 - how to show the selcted value selected in CakePHP selectbox 如何使用mysql从php的selectbox获取选项值? - How to get option value from a selectbox in php using mysql? 如何在一列中插入多个选择框项 - How to insert multiple selectbox item in one column 如何在CakePHP中手动转义mySQL数据库插入的布尔值? - How to manually escape a boolean value for a mySQL Database insert in CakePHP? 在cakephp中使用saveField函数或其他函数进行多值插入 - multiple value insert using saveField function or other function in cakephp 如何使用Codeigniter在MySQL中插入多个复选框值 - How to insert multiple checkbox value in mysql using codeigniter 如何使用复选框对应的值向MySQL插入多个数据? - how to insert multiple data to mysql using checkbox corresponding value? 如何在后续的MULTIPLE插入语句(在PHP和MYSQL中)中使用mysql_insert_id的最新插入中的值? - How do I use the value from the latest insert using mysql_insert_id in subsequent MULTIPLE insert statements (in PHP and MYSQL)? 使用Ajax jQuery cakephp的动态相关选择框 - Dynamic Dependent Selectbox Using Ajax jQuery cakephp 如何使用Ajax使用第一个选择框的值更新jquery中的第二个选择框? - How to use Ajax to update a second selectbox in jquery using the first selectbox's value?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM