dongyongju9560 2015-01-27 03:19
浏览 92
已采纳

在PostgreSQL上错误ILIKE

I've a project that use PostgreSQL and new with it. Below is the error that i was facing. I also has searched on google but cannot find the solution.

Fatal error: Call to undefined method CI_DB_postgre_driver::ilike() in D:\htdocs\poes\system\applicationapyd\classes\datafilter.php on line 162

I'm using codeigniter framework. This code is from datafilter.php $this->db->ilike($name, $value); On my controller,

$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";
  • 写回答

2条回答 默认 最新

  • dtvpl739577 2015-01-29 03:25
    关注

    I just solve the issue, need to add this function in system/database/DB_active_rec.php to use 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;
    }
    

    source from https://ellislab.com/forums/viewthread/87725/#808269

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 docker环境配置
  • ¥20 绿盟安全扫描--检测到目标站点存在javascript框架库漏洞
  • ¥30 Android STD快速启动
  • ¥15 如何使用simulink建立一个永磁同步直线电机模型?
  • ¥30 天体光谱图的的绘制并得到星表
  • ¥15 PointNet++的onnx模型只能使用一次
  • ¥20 西南科技大学数字信号处理
  • ¥15 有两个非常“自以为是”烦人的问题急期待大家解决!
  • ¥30 STM32 INMP441无法读取数据
  • ¥15 R语言绘制密度图,一个密度曲线内fill不同颜色如何实现