mirror of
https://github.com/YGGverse/YGGo.git
synced 2025-01-09 06:17:52 +00:00
fix max_matches error
This commit is contained in:
parent
3917ca8d4f
commit
fcee7f62ef
@ -11,9 +11,15 @@ class SphinxQL {
|
|||||||
$this->_sphinx->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
|
$this->_sphinx->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function searchHostPages(string $keyword, int $start, int $limit) {
|
public function searchHostPages(string $keyword, int $start, int $limit, int $maxMatches) {
|
||||||
|
|
||||||
$query = $this->_sphinx->prepare('SELECT * FROM `hostPage` WHERE MATCH(?) LIMIT ' . (int) $start . ',' . (int) $limit);
|
$query = $this->_sphinx->prepare('SELECT * FROM `hostPage`
|
||||||
|
|
||||||
|
WHERE MATCH(?)
|
||||||
|
|
||||||
|
LIMIT ' . (int) ($start > $maxMatches ? ($maxMatches > 0 ? $maxMatches - 1 : 0) : $start) . ',' . (int) $limit . '
|
||||||
|
|
||||||
|
OPTION `max_matches`=' . (int) ($maxMatches > 1 ? $maxMatches : 1));
|
||||||
|
|
||||||
$query->execute([$keyword]);
|
$query->execute([$keyword]);
|
||||||
|
|
||||||
|
@ -29,8 +29,8 @@ if (API_ENABLED) {
|
|||||||
$page = !empty($_GET['page']) ? Filter::url($_GET['page']) : 1;
|
$page = !empty($_GET['page']) ? Filter::url($_GET['page']) : 1;
|
||||||
|
|
||||||
// Make search request
|
// Make search request
|
||||||
$sphinxResults = $sphinx->searchHostPages('"' . $query . '"', $page * API_SEARCH_PAGINATION_RESULTS_LIMIT - API_SEARCH_PAGINATION_RESULTS_LIMIT, API_SEARCH_PAGINATION_RESULTS_LIMIT);
|
|
||||||
$sphinxResultsTotal = $sphinx->searchHostPagesTotal('"' . $query . '"');
|
$sphinxResultsTotal = $sphinx->searchHostPagesTotal('"' . $query . '"');
|
||||||
|
$sphinxResults = $sphinx->searchHostPages('"' . $query . '"', $page * API_SEARCH_PAGINATION_RESULTS_LIMIT - API_SEARCH_PAGINATION_RESULTS_LIMIT, API_SEARCH_PAGINATION_RESULTS_LIMIT, $sphinxResultsTotal);
|
||||||
|
|
||||||
// Generate results
|
// Generate results
|
||||||
$dbResults = [];
|
$dbResults = [];
|
||||||
|
@ -106,13 +106,13 @@ if (filter_var($q, FILTER_VALIDATE_URL) && preg_match(CRAWL_URL_REGEXP, $q)) {
|
|||||||
// Search request
|
// Search request
|
||||||
if (!empty($q)) {
|
if (!empty($q)) {
|
||||||
|
|
||||||
$results = $sphinx->searchHostPages('"' . $q . '"', $p * WEBSITE_PAGINATION_SEARCH_RESULTS_LIMIT - WEBSITE_PAGINATION_SEARCH_RESULTS_LIMIT, WEBSITE_PAGINATION_SEARCH_RESULTS_LIMIT);
|
|
||||||
$resultsTotal = $sphinx->searchHostPagesTotal('"' . $q . '"');
|
$resultsTotal = $sphinx->searchHostPagesTotal('"' . $q . '"');
|
||||||
|
$results = $sphinx->searchHostPages('"' . $q . '"', $p * WEBSITE_PAGINATION_SEARCH_RESULTS_LIMIT - WEBSITE_PAGINATION_SEARCH_RESULTS_LIMIT, WEBSITE_PAGINATION_SEARCH_RESULTS_LIMIT, $resultsTotal);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$results = [];
|
|
||||||
$resultsTotal = 0;
|
$resultsTotal = 0;
|
||||||
|
$results = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
Loading…
Reference in New Issue
Block a user