|
发表于 2012-8-29 17:14:10
|
显示全部楼层
本帖最后由 haileCI 于 2012-8-29 17:56 编辑
public function or_like_open()
{
$open='(';
$prefix = (count($this->ar_like) == 0) ? '' : ' OR ';
$this->ar_like[] = $prefix.$open;
if ($this->ar_caching === true)
{
$this->ar_cache_like[] = $prefix.$open;
$this->ar_cache_exists[] = 'like';
}
}
public function or_like_close()
{
$close=')';
$this->ar_like[] =$close;
if ($this->ar_caching === true)
{
$this->ar_cache_like[] = $close;
$this->ar_cache_exists[] = 'like';
}
}
public function like_open()
{
$open='(';
$prefix = (count($this->ar_like) == 0) ? '' : ' AND ';
$this->ar_like[] = $prefix.$open;
if ($this->ar_caching === true)
{
$this->ar_cache_like[] = $prefix.$open;
$this->ar_cache_exists[] = 'like';
}
}
public function like_close()
{
$close=')';
$this->ar_like[] =$close;
if ($this->ar_caching === true)
{
$this->ar_cache_like[] = $close;
$this->ar_cache_exists[] = 'like';
}
}
在DB指定类中加入上面几个个函数
在protected function _like()
中 的适当
倒数几行中加入 即可
if(trim(end($this->ar_like))=='OR (' OR trim(end($this->ar_like))=='(')
{
$like_statement= trim($like_statement,$prefix);
}
if(trim(end($this->ar_like))=='AND (' OR trim(end($this->ar_like))=='(')
{
$like_statement= trim($like_statement,$prefix);
}
使用的时候 先 $this->db->or_like_open() //类似 or (
//这里是很多or_like
or_like 结束时候 用 $this->db->or_like_close(); 类似 )
|
|