Call to undefined method CI_DB_mysql_driver::num_rows()

别等时光非礼了梦想. 提交于 2019-12-02 17:14:50

问题


<?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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!