我有一个使用PostgreSQL的项目和新的。以下是我所面临的错误。我也在谷歌搜索但找不到解决方案。
致命错误:在第162行的D:\ htdocs \ poes \ system \ application \ rapyd \ classes \ datafilter.php中调用未定义的方法CI_DB_postgre_driver :: ilike()
我正在使用codeigniter框架。此代码来自datafilter.php $this->db->ilike($name, $value);
在我的控制器上,
$query1 = "SELECT DISTINCT users.* FROM users LEFT JOIN login ON users.user_id=login.login_user_id;";
$filter->db->query($query1);
$filter->name = new inputField("Name :", "user_name");
$filter->name->clause = "ilike";
答案 0 :(得分:0)
我刚刚解决了这个问题,需要在system / database / DB_active_rec.php中添加这个函数才能使用ilike
function ilike($field, $match = '', $side = 'both')
{
return $this->_ilike($field, $match, 'AND ', $side);
}
function _ilike($field, $match = '', $type = 'AND ', $side = 'both', $not = '')
{
if ( ! is_array($field))
{
$field = array($field => $match);
}
foreach ($field as $k => $v)
{
$k = $this->_protect_identifiers($k);
$prefix = (count($this->ar_like) == 0) ? '' : $type;
$v = $this->escape_like_str($v);
if ($side == 'before')
{
$like_statement = $prefix." $k $not ILIKE '%{$v}'";
}
elseif ($side == ‘after’)
{
$like_statement = $prefix." $k $not ILIKE '{$v}%'";
}
else
{
$like_statement = $prefix." $k $not ILIKE '%{$v}%'";
}
// some platforms require an escape sequence definition for ILIKE wildcards
if ($this->_like_escape_str != ‘’)
{
$like_statement = $like_statement.sprintf($this->_like_escape_str, $this->_like_escape_chr);
}
$this->ar_like[] = $like_statement;
if ($this->ar_caching === TRUE)
{
$this->ar_cache_ilike[] = $like_statement;
$this->ar_cache_exists[] = 'ilike';
}
}
return $this;
}
的来源
答案 1 :(得分:0)
像这样
$param = "%".urldecode($this->uri->segment(4))."%";
if(!empty($this->uri->segment(4))){
$this->db->where("name ilike",$param);
}