【发布时间】:2016-09-15 22:39:45
【问题描述】:
我想问一下杂货杂货中可以自动计算的功能。
例如:我有一些列 a、b 和 total_a_b。我已经使用了函数 callback_column 但它现在可以正常工作了,callback_column 只是在视图页面上显示结果,它不能自动保存到数据库。有什么功能可以参考吗?以及是否有办法以字段形式显示自动计算?
这是我的代码:
public function try() {
$crud = new grocery_CRUD();
$crud->set_table('try');
$crud->columns('a', 'b', 'total');
$crud->callback_column('total', array($this, '_callback_column_total'));
$output = $crud->render();
$this->_example_output($output);
}
public function _callback_column_total ($value, $row) {
$a = $row->a;
$b = $row->b;
$total=$a + $b;
return $total;
}
【问题讨论】:
标签: php grocery-crud