在codeigniter mysql中使用where条件获取空白页面

时间:2017-09-20 09:14:09

标签: php mysql codeigniter

嗨我在使用之后使用了mysql中的where条件,如果我运行网站获取空白页面。

其实我是QA部门,发展,管理部门的三个部门。

在Mysql中我已经使用where条件来获取QA部门列表但是获得空白页面。

这是我的代码:

控制器:

public function index()
{
    $data['records2'] = $this->index_model->get_ourteammembers();
    $data['mainpage'] = "our-team";
    $this->load->view('templates/template',$data);
}

模型

function get_ourteammembers()
{

    $this->db->select('T.*');
    $this->db->from('ourteam AS T');
    $this->db->where('T.department'='QA Department');
    $q = $this->db->get();
    if($q->num_rows()>0)
    {
        return $q->result();
    }
    else 
    {
        return false;
    }
}

2 个答案:

答案 0 :(得分:3)

试试这个

function get_ourteammembers()
{

    $this->db->select('T.*');
    $this->db->from('ourteam AS T');
    $this->db->where('T.department','QA Department');
    $q = $this->db->get();
    if($q->num_rows()>0)
    {
        return $q->result();
    }
    else 
    {
        return false;
    }
}

答案 1 :(得分:0)

根据CodeIgniter文件,您必须使用','而不是' ='

$this->db->where('T.department'='QA Department');

$this->db->where('T.department','QA Department');