codeigniter count_all_results

后端 未结 7 1759
眼角桃花
眼角桃花 2021-02-14 03:37

I\'m working with the latest codeIgniter released, and i\'m also working with jquery datatables from datatables.net

I

7条回答
  •  粉色の甜心
    2021-02-14 03:57

    Try this

     /**
            * @param $column_name   :   Use In Choosing Column name
            * @param $where         :   Use In Condition Statement
            * @param $table_name    :   Name of Database Table
            * Description           :   Count all results   
            */ 
        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
        }
    

    Then Simple Call the Method

    Like this

    $this->my_model->count_all_results(['column_name'],['where'],['table name']);
    

提交回复
热议问题