本文整理汇总了PHP中rcube_db::ilike方法的典型用法代码示例。如果您正苦于以下问题:PHP rcube_db::ilike方法的具体用法?PHP rcube_db::ilike怎么用?PHP rcube_db::ilike使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rcube_db
的用法示例。
在下文中一共展示了rcube_db::ilike方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fulltext_sql_where
/**
* Helper method to compose SQL where statements for fulltext searching
*/
private function fulltext_sql_where($value, $mode, $col = 'words', $bool = 'AND')
{
$WS = ' ';
$AS = $col == 'words' ? $WS : self::SEPARATOR;
$words = $col == 'words' ? rcube_utils::normalize_string($value, true) : array($value);
$where = array();
foreach ($words as $word) {
if ($mode & rcube_addressbook::SEARCH_STRICT) {
$where[] = '(' . $this->db->ilike($col, $word) . ' OR ' . $this->db->ilike($col, $word . $AS . '%') . ' OR ' . $this->db->ilike($col, '%' . $AS . $word . $AS . '%') . ' OR ' . $this->db->ilike($col, '%' . $AS . $word) . ')';
} else {
if ($mode & rcube_addressbook::SEARCH_PREFIX) {
$where[] = '(' . $this->db->ilike($col, $word . '%') . ' OR ' . $this->db->ilike($col, '%' . $AS . $word . '%') . ')';
} else {
$where[] = $this->db->ilike($col, '%' . $word . '%');
}
}
}
return count($where) ? '(' . join(" {$bool} ", $where) . ')' : '';
}
示例2: fulltext_sql_where
/**
* Helper method to compose SQL where statements for fulltext searching
*/
private function fulltext_sql_where($value, $mode, $col = 'words', $bool = 'AND')
{
$WS = ' ';
$AS = $col == 'words' ? $WS : self::SEPARATOR;
$words = $col == 'words' ? rcube_utils::normalize_string($value, true) : array($value);
$where = array();
foreach ($words as $word) {
switch ($mode) {
case 1:
// strict
$where[] = '(' . $this->db->ilike($col, $word . '%') . ' OR ' . $this->db->ilike($col, '%' . $WS . $word . $WS . '%') . ' OR ' . $this->db->ilike($col, '%' . $WS . $word) . ')';
break;
case 2:
// prefix
$where[] = '(' . $this->db->ilike($col, $word . '%') . ' OR ' . $this->db->ilike($col, '%' . $AS . $word . '%') . ')';
break;
default:
// partial
$where[] = $this->db->ilike($col, '%' . $word . '%');
}
}
return count($where) ? '(' . join(" {$bool} ", $where) . ')' : '';
}
示例3: search
/**
* Search contacts
*
* @param mixed $fields The field name of array of field names to search in
* @param mixed $value Search value (or array of values when $fields is array)
* @param int $mode Matching mode:
* 0 - partial (*abc*),
* 1 - strict (=),
* 2 - prefix (abc*)
* @param boolean $select True if results are requested, False if count only
* @param boolean $nocount True to skip the count query (select only)
* @param array $required List of fields that cannot be empty
*
* @return object rcube_result_set Contact records and 'count' value
*/
function search($fields, $value, $mode = 0, $select = true, $nocount = false, $required = array())
{
if (!is_array($fields)) {
$fields = array($fields);
}
if (!is_array($required) && !empty($required)) {
$required = array($required);
}
$where = $and_where = array();
$mode = intval($mode);
$WS = ' ';
$AS = self::SEPARATOR;
foreach ($fields as $idx => $col) {
// direct ID search
if ($col == 'ID' || $col == $this->primary_key) {
$ids = !is_array($value) ? explode(self::SEPARATOR, $value) : $value;
$ids = $this->db->array2list($ids, 'integer');
$where[] = 'c.' . $this->primary_key . ' IN (' . $ids . ')';
continue;
} else {
if ($col == '*') {
$words = array();
foreach (explode($WS, rcube_utils::normalize_string($value)) as $word) {
switch ($mode) {
case 1:
// strict
$words[] = '(' . $this->db->ilike('words', $word . '%') . ' OR ' . $this->db->ilike('words', '%' . $WS . $word . $WS . '%') . ' OR ' . $this->db->ilike('words', '%' . $WS . $word) . ')';
break;
case 2:
// prefix
$words[] = '(' . $this->db->ilike('words', $word . '%') . ' OR ' . $this->db->ilike('words', '%' . $WS . $word . '%') . ')';
break;
default:
// partial
$words[] = $this->db->ilike('words', '%' . $word . '%');
}
}
$where[] = '(' . join(' AND ', $words) . ')';
} else {
$val = is_array($value) ? $value[$idx] : $value;
// table column
if (in_array($col, $this->table_cols)) {
switch ($mode) {
case 1:
// strict
$where[] = '(' . $this->db->quoteIdentifier($col) . ' = ' . $this->db->quote($val) . ' OR ' . $this->db->ilike($col, $val . $AS . '%') . ' OR ' . $this->db->ilike($col, '%' . $AS . $val . $AS . '%') . ' OR ' . $this->db->ilike($col, '%' . $AS . $val) . ')';
break;
case 2:
// prefix
$where[] = '(' . $this->db->ilike($col, $val . '%') . ' OR ' . $this->db->ilike($col, $AS . $val . '%') . ')';
break;
default:
// partial
$where[] = $this->db->ilike($col, '%' . $val . '%');
}
} else {
if (in_array($col, $this->fulltext_cols)) {
foreach (rcube_utils::normalize_string($val, true) as $word) {
switch ($mode) {
case 1:
// strict
$words[] = '(' . $this->db->ilike('words', $word . $WS . '%') . ' OR ' . $this->db->ilike('words', '%' . $AS . $word . $WS . '%') . ' OR ' . $this->db->ilike('words', '%' . $AS . $word) . ')';
break;
case 2:
// prefix
$words[] = '(' . $this->db->ilike('words', $word . '%') . ' OR ' . $this->db->ilike('words', $AS . $word . '%') . ')';
break;
default:
// partial
$words[] = $this->db->ilike('words', '%' . $word . '%');
}
}
$where[] = '(' . join(' AND ', $words) . ')';
}
if (is_array($value)) {
$post_search[$col] = mb_strtolower($val);
}
}
}
}
}
foreach (array_intersect($required, $this->table_cols) as $col) {
$and_where[] = $this->db->quoteIdentifier($col) . ' <> ' . $this->db->quote('');
}
if (!empty($where)) {
//.........这里部分代码省略.........