本文介绍了Yii框架如何更新所有记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用 Yii 框架.
I am using Yii framework.
/view/update.php
/view/update.php
<?php
echo CHtml::beginForm();
foreach ($items as $i=>$item):
echo '<tr>';
echo '<td>'.$item['name'].'</td>';
echo '<td>'.$item['c1'].'</td>';
echo '<td>'. count(cos::model()->findAll(array(
'condition'=>'cos2='.$item['id'],))).'</td>';
echo '<td>'. CHtml::activeCheckBox($item, "[$i]c2").'</td>';
echo '<td>'. CHtml::activeCheckBox($item, "[$i]c3").'</td>';
echo '<td>'. CHtml::activeCheckBox($item, "[$i]c4").'</td>';
echo '<td>edit</td>';
echo '</tr>';
endforeach;
echo '</table>';
echo CHtml::submitButton('Save');
echo CHtml::endForm();
?>
如何一次写入所有记录?
how can I write all the records at once?
推荐答案
你可以参考这篇关于如何使用 Yii update all 的参考
you can use this as reference on how to use the Yii update all
CActiveRecord::updateAll($attributes, $condition='', $params=array())
http://www.saidur-rahman.com/yii-how-to-updateall-works/
这篇关于Yii框架如何更新所有记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!