【问题标题】:Codeigniter num rows error [duplicate]Codeigniter num行错误[重复]
【发布时间】:2015-09-25 14:56:35
【问题描述】:

当我运行这段代码时,它工作正常

  echo $str = $this->db->last_query();

这一行之后

 if($selectRecords->num_rows()>0){
 //some action
}

我正在解决这个错误

<br />
<b>Fatal error</b>:  Call to undefined method CI_DB_mysql_driver::num_rows() in <b>/vagrant/application/controllers/applicationtable.php</b> on line <b>1240</b><br />

这是我的代码

<?php
    public function xyz(){
            $selectRecords=$this->db->select(" (SELECT name FROM $this->reportTable WHERE id=$this->reportType) AS `$this->reportLabel`, 
                        SUM(rashi_given) AS `total` ,
                        SUM(rashi_accepted) AS atotal");
              $selectRecords->join('type', 'applicants.type=type.id', 'left');
              $selectRecords->group_by($this->reportType); 
              $selectRecords->get('applicants');
             echo $str = $this->db->last_query(); 
          if($selectRecords->num_rows()>0){

           }
     }


    ?>

有什么问题请帮忙

【问题讨论】:

    标签: php codeigniter


    【解决方案1】:

    您检查了错误的变量。见Call to undefined method CI_DB_mysql_driver::num_rows()

    $rs = $selectRecords->get('applicants');
    echo $str = $this->db->last_query(); 
    
    if($rs->num_rows()>0){
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-08-09
      • 1970-01-01
      • 2013-06-10
      • 1970-01-01
      • 1970-01-01
      • 2014-01-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多