php codeigniter count rows [duplicate] php codeigniter count rows [duplicate] codeigniter codeigniter

php codeigniter count rows [duplicate]


You could use the helper function $query->num_rows()

It returns the number of rows returned by the query. You can use like this:

$query = $this->db->query('SELECT * FROM my_table');echo $query->num_rows();


Use this code:

$this->db->where(['id'=>2])->from("table name")->count_all_results();

or

$this->db->from("table name")->count_all_results();


You may try this one

    $this->db->where('field1',$filed1);    $this->db->where('filed2',$filed2);    $result = $this->db->get('table_name')->num_rows();