调用未定义的方法CI_DB_mysql_driver :: num_rows() [英] Call to undefined method CI_DB_mysql_driver::num_rows()

查看:661
本文介绍了调用未定义的方法CI_DB_mysql_driver :: num_rows()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<?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();

      }
}

上述代码给出错误, p>

Above code gives error,


调用未定义的方法CI_DB_mysql_driver :: num_rows()

Call to undefined method CI_DB_mysql_driver::num_rows()


推荐答案

由查询返回的行数。 num_rows()您首先执行查询,然后可以检查你有多少行。

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 是查询结果对象分配给的变量:

$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

这篇关于调用未定义的方法CI_DB_mysql_driver :: num_rows()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆