Php 如何向yii中的mysql表发送多个值
我不熟悉PHP和Yii框架。如何在数据库中插入多个问题 这是表单视图代码Php 如何向yii中的mysql表发送多个值,php,mysql,yii,foreach,Php,Mysql,Yii,Foreach,我不熟悉PHP和Yii框架。如何在数据库中插入多个问题 这是表单视图代码 <?php echo $form->textField($model,'questions',array('id'=>"content_#index#_question textBox")); ?> <?php echo $form->textField($model,'questions',array('id'=>"content_#index#_question textBo
<?php echo $form->textField($model,'questions',array('id'=>"content_#index#_question textBox")); ?>
<?php echo $form->textField($model,'questions',array('id'=>"content_#index#_question textBox")); ?>
实际上,我的过程是创建多个问题和答案,但现在出现了如下错误
“为foreach()提供的参数无效”,通过使用我的代码以及如何向mysql表发送多个问题和答案…试试这个
<?php echo $form->textField($model,'questions[]',array('id'=>"content_#index#_question textBox")); ?>
更改此选项
foreach ($model['questions'] as $value) {
$model->questions = $value;
}
$model->save();
关于这个
foreach ($model['questions'] as $value) {
$model->questions = $value;
$model->save();
}
你想做什么?插入一个问题的多个答案。或者插入问题和答案栏我必须插入多个问题和答案,但这里我只提到了问题。谢谢你的回答,我确实按照你说的做了更改,但现在只插入了一行。。。
foreach ($model['questions'] as $value) {
$model->questions = $value;
$model->save();
}