【问题标题】:Codeigniter problem with retriving value from database从数据库中检索值的 Codeigniter 问题
【发布时间】:2010-07-30 01:09:34
【问题描述】:

好的,我正在尝试检索成员独立且活跃的行数。

我已将问题缩小到我的模型。一切正常,直到我在 get_where 中添加了第二个子句

这是我的模型函数

函数 count_individual_active_members() { $query = $this->db->get_where('Membership', array('Membership_Status' => 'Active', 'Membership_cat' => '个人')); 返回 $query->num_rows(); }

我做错了什么,我该如何解决?

谢谢

【问题讨论】:

    标签: activerecord codeigniter mysql get


    【解决方案1】:

    对不起各位,

    我自己修复了它:D

    函数 count_individual_active_members() { $query = $this->db->where(array('Membership_Status' => 'Active', 'Membership_Cat' => 'Individual')); $query = $this->db->get('Membership'); 返回 $query->num_rows(); }

    【讨论】:

    • 不确定你做了什么来排除故障和修复它,但使用 $this->db->last_query() 来准确找出执行了什么查询通常很有帮助(这样你就可以看到你的搞砸了)。
    • 仅仅是列名错误吗? Membership_cat 而不是 Membership_Cat。 SQL 对列名区分大小写。
    猜你喜欢
    • 2017-11-11
    • 1970-01-01
    • 2010-11-09
    • 1970-01-01
    • 2021-12-14
    • 1970-01-01
    • 2017-01-15
    • 1970-01-01
    • 2011-01-16
    相关资源
    最近更新 更多