本文整理汇总了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))) {
//.........这里部分代码省略.........