0
我想問一下可以在食品雜貨中進行自動計算的功能。自動計算食品雜貨crud
例如:我有一些列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;
}