CodeIgniter Active Record - Get number of returned rows

前端 未结 11 1991
不思量自难忘°
不思量自难忘° 2020-12-12 22:48

I\'m very new to CodeIgniter and Active Record in particular, I know how to do this well in normal SQL but I\'m trying to learn.

How can I select some data from one

11条回答
  •  伪装坚强ぢ
    2020-12-12 22:59

    This code segment for your Model

    function getCount($tblName){
        $query = $this->db->get($tblName);
        $rowCount = $query->num_rows();
        return $rowCount;       
    }
    

    This is for controlr

      public function index() {
        $data['employeeCount']= $this->CMS_model->getCount("employee");
        $this->load->view("hrdept/main",$data);
    }
    

    This is for view

    This code is used in my project and is working properly.

    result

提交回复
热议问题