當前位置: 首頁>>代碼示例>>PHP>>正文


PHP rcube_db::ilike方法代碼示例

本文整理匯總了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) . ')' : '';
 }
開發者ID:jimjag,項目名稱:roundcubemail,代碼行數:22,代碼來源:rcube_contacts.php

示例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) . ')' : '';
 }
開發者ID:normalnorge,項目名稱:roundcubemail,代碼行數:26,代碼來源:rcube_contacts.php

示例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)) {
//.........這裏部分代碼省略.........
開發者ID:netcon-source,項目名稱:roundcubemail,代碼行數:101,代碼來源:rcube_contacts.php


注:本文中的rcube_db::ilike方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。