mirror of
https://github.com/e107inc/e107.git
synced 2025-08-04 13:47:31 +02:00
Merge pull request #3257 from SimSync/fix_3065
Fixes #3065 Added a method to translate wildcards to mysql counterparts
This commit is contained in:
@@ -3996,6 +3996,29 @@ class e_admin_controller_ui extends e_admin_controller
|
|||||||
return $qry;
|
return $qry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fix search string by replacing the commonly used '*' wildcard
|
||||||
|
* with the mysql represenation of it '%' and '?' with '_' (single character)
|
||||||
|
*
|
||||||
|
* @param string $search
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
protected function fixSearchWildcards($search)
|
||||||
|
{
|
||||||
|
$search = trim($search);
|
||||||
|
if (empty($search))
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
// strip wildcard on the beginning and the end
|
||||||
|
while (substr($search, 0, 1) == '*') $search = substr($search, 1);
|
||||||
|
while (substr($search, -1) == '*') $search = substr($search, 0, -1);
|
||||||
|
|
||||||
|
// replace "*" wildcard with mysql wildcard "%"
|
||||||
|
return str_replace(array('*', '?'), array('%', '_'), $search);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO - abstract, array return type, move to parent?
|
// TODO - abstract, array return type, move to parent?
|
||||||
protected function _modifyListQry($raw = false, $isfilter = false, $forceFrom = false, $forceTo = false, $listQry = '')
|
protected function _modifyListQry($raw = false, $isfilter = false, $forceFrom = false, $forceTo = false, $listQry = '')
|
||||||
@@ -4011,7 +4034,7 @@ class e_admin_controller_ui extends e_admin_controller
|
|||||||
$filter = array();
|
$filter = array();
|
||||||
|
|
||||||
|
|
||||||
$searchQuery = $tp->toDB($request->getQuery('searchquery', ''));
|
$searchQuery = $this->fixSearchWildcards($tp->toDB($request->getQuery('searchquery', '')));
|
||||||
$searchFilter = $this->_parseFilterRequest($request->getQuery('filter_options', ''));
|
$searchFilter = $this->_parseFilterRequest($request->getQuery('filter_options', ''));
|
||||||
|
|
||||||
if(E107_DEBUG_LEVEL == E107_DBG_SQLQUERIES)
|
if(E107_DEBUG_LEVEL == E107_DBG_SQLQUERIES)
|
||||||
|
Reference in New Issue
Block a user