问题
<?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()
回答1:
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
回答2:
class Welcome_model extends CI_Model {
public function select(){
echo $this->db->get('av_home')->num_rows();
}
}
来源:https://stackoverflow.com/questions/31625729/call-to-undefined-method-ci-db-mysql-drivernum-rows