1
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Welcome_model extends CI_Model {

      public function select(){

                  $this->db->get('av_home');
                  echo $this->db->num_rows();

      }
}

Above code gives error,

Call to undefined method CI_DB_mysql_driver::num_rows()

2 Answers 2

7

The number of rows returned by the query.With num_rows() you first perform the query, and then you can check how many rows you got.

$query is the variable that the query result object is assigned to:

 $query=$this->db->get('av_home');// assign to a variable
 echo $query->num_rows();// then use num rows
Sign up to request clarification or add additional context in comments.

Comments

0
class Welcome_model extends CI_Model {

      public function select(){

            echo $this->db->get('av_home')->num_rows();

      }
}

1 Comment

Please consider editing your answer to include an explanation of how your code works.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.