num_rows的codeigniter问题(可能的错误?) [英] codeigniter issue with num_rows (possible bug?)

查看:71
本文介绍了num_rows的codeigniter问题(可能的错误?)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Codeignitor的新手,在选择查询时一直遇到重大问题。我最初以为我是新手(也许是新手),但事实是,我花了3天时间研究指南和视频,以为这是一个问题。

Im new to codeignitor and i have been having major issues with selecting queries. I originally thought it was me being a newbie (and maybe it is) but the fact that ive spent 3 days studying guides and videos im thinking its an issue.

使用时这:

if ( $q->num_rows > 0 )

我不断收到错误:
试图获取非对象的属性

我正在遵循创建登录身份验证系统的指南。我清楚地输入了教师的内容,但是我无法通过该错误,并且尝试获取行数据时,不仅是本指南(我遵循的其他指南)也导致相同的错误。

I'm following a guide to create a login authentication system. I'm clearly typing what the instructor has, but i cant get passed that error, and its not just this guide, other guides i have followed, has resulted in the same error when trying to grab row data.

这是我的模型:

public function verify_user($email, $password)
{
$q = $this
        ->db
        ->where('email_address', $email)
        ->where('password', sha1($password))
        ->limit(1)
        ->get('users');

   if ( $q->num_rows > 0 ) {
        return $q->row();
       }
       return false;
}

我能提供的任何帮助将不胜感激!

Any help i could get on this would be greatly appreciated!

推荐答案

更改

$q->num_rows

$q->num_rows()

请参见此处: codeigniter指南

尝试做:

echo $this->db->last_query(); //after $this->db ...... get('users');

检查生成的sql,以查看sql语句中是否有错误

to check your generated sql to see for any errors you have in your sql statement

这篇关于num_rows的codeigniter问题(可能的错误?)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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