mirror of
https://github.com/processwire/processwire.git
synced 2025-08-09 00:06:55 +02:00
Fix issue processwire/processwire-issues#1199
This commit is contained in:
@@ -164,7 +164,13 @@ class PageFinder extends Wire {
|
|||||||
* using it. Kept for further experimenting.
|
* using it. Kept for further experimenting.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
'useSortsAfter' => false,
|
'useSortsAfter' => false,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Options passed to DatabaseQuery::bindOptions() for primary query generated by this PageFinder
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
'bindOptions' => array(),
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1386,6 +1392,9 @@ class PageFinder extends Wire {
|
|||||||
|
|
||||||
/** @var DatabaseQuerySelect $query */
|
/** @var DatabaseQuerySelect $query */
|
||||||
$query = $this->wire(new DatabaseQuerySelect());
|
$query = $this->wire(new DatabaseQuerySelect());
|
||||||
|
if(!empty($options['bindOptions'])) {
|
||||||
|
foreach($options['bindOptions'] as $k => $v) $query->bindOption($k, $v);
|
||||||
|
}
|
||||||
$query->select($columns);
|
$query->select($columns);
|
||||||
$query->from("pages");
|
$query->from("pages");
|
||||||
$query->groupby($options['returnParentIDs'] ? 'pages.parent_id' : 'pages.id');
|
$query->groupby($options['returnParentIDs'] ? 'pages.parent_id' : 'pages.id');
|
||||||
@@ -1665,7 +1674,11 @@ class PageFinder extends Wire {
|
|||||||
$query = $pageFinder->find($selectors, array(
|
$query = $pageFinder->find($selectors, array(
|
||||||
'returnQuery' => true,
|
'returnQuery' => true,
|
||||||
'returnVerbose' => false,
|
'returnVerbose' => false,
|
||||||
'findAll' => true
|
'findAll' => true,
|
||||||
|
'bindOptions' => array(
|
||||||
|
'prefix' => 'pfor',
|
||||||
|
'global' => true,
|
||||||
|
)
|
||||||
));
|
));
|
||||||
if($n > 0) $sql .= " \n\tOR pages.id IN (\n";
|
if($n > 0) $sql .= " \n\tOR pages.id IN (\n";
|
||||||
$query->set('groupby', array());
|
$query->set('groupby', array());
|
||||||
@@ -2415,8 +2428,15 @@ class PageFinder extends Wire {
|
|||||||
// handle one or more space-separated full words match to 'name' field in any order
|
// handle one or more space-separated full words match to 'name' field in any order
|
||||||
$s = '';
|
$s = '';
|
||||||
foreach(explode(' ', $value) as $n => $word) {
|
foreach(explode(' ', $value) as $n => $word) {
|
||||||
$word = $sanitizer->pageName($word, Sanitizer::toAscii);
|
$word = $sanitizer->pageName($word, Sanitizer::toAscii);
|
||||||
$bindKey = $query->bindValueGetKey('[[:<:]]' . $word . '[[:>:]]');
|
$mySQL8 = false; // @todo add version check
|
||||||
|
if($mySQL8) {
|
||||||
|
// confirm the statement below works in MySQL 8.x because "\\b" has
|
||||||
|
// very different regex meaning between 8.x and versions prior to it
|
||||||
|
$bindKey = $query->bindValueGetKey("\\b$word\\b");
|
||||||
|
} else {
|
||||||
|
$bindKey = $query->bindValueGetKey('[[:<:]]' . $word . '[[:>:]]');
|
||||||
|
}
|
||||||
$s .= ($s ? ' AND ' : '') . "$table.$field RLIKE $bindKey";
|
$s .= ($s ? ' AND ' : '') . "$table.$field RLIKE $bindKey";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user