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


PHP DevblocksPlatform::getSearchService方法代碼示例

本文整理匯總了PHP中DevblocksPlatform::getSearchService方法的典型用法代碼示例。如果您正苦於以下問題:PHP DevblocksPlatform::getSearchService方法的具體用法?PHP DevblocksPlatform::getSearchService怎麽用?PHP DevblocksPlatform::getSearchService使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DevblocksPlatform的用法示例。


在下文中一共展示了DevblocksPlatform::getSearchService方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getWhereSQL

 public function getWhereSQL($fields)
 {
     $db = DevblocksPlatform::getDatabaseService();
     $where = '';
     $db_field_name = $fields[$this->field]->db_table . '.' . $fields[$this->field]->db_column;
     // [JAS]: Operators
     switch ($this->operator) {
         case "eq":
         case "=":
             $where = sprintf("%s = %s", $db_field_name, self::_escapeSearchParam($this, $fields));
             break;
         case DevblocksSearchCriteria::OPER_EQ_OR_NULL:
             $where = sprintf("(%s = %s OR %s IS NULL)", $db_field_name, self::_escapeSearchParam($this, $fields), $db_field_name);
             break;
         case "neq":
         case "!=":
             $where = sprintf("%s != %s", $db_field_name, self::_escapeSearchParam($this, $fields));
             break;
         case "in":
             if (!is_array($this->value)) {
                 break;
             }
             $value = !empty($this->value) ? $this->value : array(-1);
             $vals = array();
             // Escape quotes
             foreach ($this->value as $idx => $val) {
                 $vals[$idx] = addslashes($val);
                 // [TODO] Test
             }
             $where = sprintf("%s IN ('%s')", $db_field_name, implode("','", $vals));
             break;
         case DevblocksSearchCriteria::OPER_NIN:
             // 'not in'
             if (!is_array($this->value)) {
                 break;
             }
             $value = !empty($this->value) ? $this->value : array(-1);
             $where = sprintf("%s NOT IN ('%s')", $db_field_name, implode("','", $value));
             break;
         case DevblocksSearchCriteria::OPER_FULLTEXT:
             // 'fulltext'
             $search = DevblocksPlatform::getSearchService();
             $value = null;
             $scope = null;
             if (!is_array($this->value)) {
                 $value = $this->value;
                 $scope = 'expert';
             } else {
                 $value = $this->value[0];
                 $scope = $this->value[1];
             }
             switch ($scope) {
                 case 'all':
                     $value = $search->prepareText($value);
                     $value = '+' . str_replace(' ', ' +', $value);
                     break;
                 case 'any':
                     $value = $search->prepareText($value);
                     break;
                 case 'phrase':
                     $value = '"' . $search->prepareText($value) . '"';
                     break;
                 default:
                 case 'expert':
                     break;
             }
             $where = sprintf("MATCH(%s) AGAINST (%s IN BOOLEAN MODE)", $db_field_name, $db->qstr($value));
             break;
         case DevblocksSearchCriteria::OPER_LIKE:
             // 'like'
             $where = sprintf("%s LIKE %s", $db_field_name, str_replace('*', '%', self::_escapeSearchParam($this, $fields)));
             break;
         case DevblocksSearchCriteria::OPER_NOT_LIKE:
             // 'not like'
             $where = sprintf("%s NOT LIKE %s", $db_field_name, str_replace('*', '%%', self::_escapeSearchParam($this, $fields)));
             break;
         case DevblocksSearchCriteria::OPER_IS_NULL:
             // 'is null'
             $where = sprintf("%s IS NULL", $db_field_name);
             break;
             /*
              * [TODO] Someday we may want to call this OPER_DATE_BETWEEN so it doesn't interfere 
              * with the operator in other uses
              */
         /*
          * [TODO] Someday we may want to call this OPER_DATE_BETWEEN so it doesn't interfere 
          * with the operator in other uses
          */
         case DevblocksSearchCriteria::OPER_BETWEEN:
             // 'between'
             if (!is_array($this->value) && 2 != count($this->value)) {
                 break;
             }
             $from_date = $this->value[0];
             if (!is_numeric($from_date)) {
                 // Translate periods into dashes on string dates
                 if (false !== strpos($from_date, '.')) {
                     $from_date = str_replace(".", "-", $from_date);
                 }
                 if (false === ($from_date = strtotime($from_date))) {
//.........這裏部分代碼省略.........
開發者ID:jstanden,項目名稱:devblocks,代碼行數:101,代碼來源:Model.php


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