Try this :) I created my model to calculate all the results.
in library_model
function count_all_results($column_name = array(),$where=array(), $table_name = array()) { $this->db->select($column_name); // If Where is not NULL if(!empty($where) && count($where) > 0 ) { $this->db->where($where); } // Return Count Column return $this->db->count_all_results($table_name[0]);//table_name array sub 0 }
Your controller will look like this
public function my_method() { $data = array( $countall = $this->model->your_method_model() ); $this->load->view('page',$data); }
Then a simple library model call in your model
function your_method_model() { return $this->library_model->count_all_results( ['id'], ['where], ['table name'] ); }
source share