当前位置: 首页>>代码示例>>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;未经允许,请勿转载。