CodeIgniter Active Record - Get number of returned rows

前端 未结 11 1987
不思量自难忘°
不思量自难忘° 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

    You can do this in two different ways:

      1. $this->db->query(); //execute the query
         $query = $this->db->get() // get query result
         $count = $query->num_rows() //get current query record.
    
      2.  $this->db->query(); //execute the query
          $query = $this->db->get() // get query result
          $count = count($query->results()) 
              or   count($query->row_array())  //get current query record.
    

提交回复
热议问题