예제 #1
0
            $action = "regexp";
            $char = "^[{$char}]";
        } else {
            $char = null;
        }
    }
}
if (is_null($char)) {
    $modx->sendErrorPage();
}
$p =& $modx->event->params;
if (!is_array($p)) {
    $p = array();
}
if (!empty($loadfilter)) {
    $field = explode(".", $field);
    $field = end($field);
    if (!empty($p['filters'])) {
        $p['filters'] = rtrim(trim($p['filters']), ";") . ";";
    }
    $p['filters'] = "AND({$loadfilter}:{$field}:{$action}:{$char})";
} else {
    $field = sqlHelper::tildeField($field);
    if ($action == 'regexp') {
        $where = $field . " REGEXP '" . $modx->db->escape($char) . "'";
    } else {
        $where = sqlHelper::LikeEscape($modx, $field, $char, '=', '[+value+]%');
    }
    $p['addWhereList'] = empty($p['addWhereList']) ? $where : sqlHelper::trimLogicalOp($p['addWhereList']) . " AND " . $where;
}
return $modx->runSnippet("DocLister", $p);
예제 #2
0
 /**
  * Экранирование строки в SQL запросе LIKE
  * @see: http://stackoverflow.com/a/3683868/2323306
  *
  * @param string $field поле по которому осуществляется поиск
  * @param string $value искомое значение
  * @param string $escape экранирующий символ
  * @param string $tpl шаблон подстановки значения в SQL запрос
  * @return string строка для подстановки в SQL запрос
  */
 public function LikeEscape($field, $value, $escape = '=', $tpl = '%[+value+]%')
 {
     return sqlHelper::LikeEscape($this->modx, $field, $value, $escape, $tpl);
 }