【问题标题】:How to keep variable value use throughout all records in clistview如何在 clistview 中的所有记录中保持变量值的使用
【发布时间】:2015-04-30 06:34:59
【问题描述】:

我用过 clistview。

我的要求是在每条记录上打印总计。

就像在 randerPartial _view.php 中一样,

第一条记录

total= total+$data->amount(value 100);
total=100;

第二条记录

total= total+$data->amount(value 100);
total=200;

第三条记录

total= total+$data->amount(value 100);
total=300;

等等……

但我无法获得总变量的最后更新值。
它覆盖每条记录中的值。如何保持变量更新和使用。

【问题讨论】:

    标签: php yii clistview


    【解决方案1】:

    更好的解决方案是在控制器中创建一个变量,例如

    class AbcController extends Controller
    {
        public $total=0;
    }
    

    然后在你的renderPartial _view.php 中使用它

    $this->total += $data->amount(value 100);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-09-20
      • 1970-01-01
      • 2015-01-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-06
      • 2021-08-25
      相关资源
      最近更新 更多