mysql哪里条件不起作用?

时间:2015-04-14 14:24:19

标签: php mysql sql codeigniter web

我已经在codeigniter中编写了我的PHP代码,但是当我设置$ limit = 1时,仍然会得到记录= = 1为什么? 我在纯SQL中编写了一个mysql查询,但问题仍然存在! 这是我的代码:

function getComment($limit)
{
    while( !$this->checkFuncState('getComment') );
    $this->lockFunc('getComment');
    $grade = $this->session->userdata('grade');
    $this->db->select('*');
    $this->db->select('m_comments.id AS `ComId`');
    $this->db->select('m_comments.approved AS `Comappr`');
    $this->db->select('m_comments.content AS `ComContent`');
    $this->db->select('m_users.hid AS `UserHid`');
    $this->db->from('m_comments');
    $this->db->join('m_users','m_comments.user_id = m_users.id');
    if( $grade == "0" || $grade == "1" )
        $this->db->where("( m_comments.approved = 0 || m_comments.approved = -15 )");
    else
        $this->db->where('m_comments.approved','0');
    $this->db->where('m_comments.seen','0');
    $this->db->limit($limit);
    $q = $this->db->get();
    $this->setComsSeen($q);
    $this->unlockFunc('getComment');
    return $q;
}

0 个答案:

没有答案