代码点火器如何使用 get_where() 在包含部分字符串的列中进行搜索


Codeigniter how to use get_where() to search in a column that contains part of a string?

如果标题令人困惑,请道歉。目前,我将其作为get_where函数的一部分:

$query = $this->db->select('*');
$query = $this->db->get_where('Accounts', array('active' => 1));
return $this->result_array($query);

如何添加到 get_where() 语句中以查找包含我告诉它要查找的字符串值的特定列?例如,我希望它也在 AccountKey 列中查找,并返回该列中包含字符串"120-"的所有行,以及 active = 1 .

你可以这样使用,你的查询将变成如下内容:

$query = $this->db
            ->select('*')
            ->from('Accounts')
            ->where('active', 1)
            ->like('AccountKey', '120-', 'after')
            ->get();