mirror of
https://github.com/YGGverse/YGGo.git
synced 2025-02-03 10:25:52 +00:00
count totals using sphinx index instead of database
This commit is contained in:
parent
bf1eeb332c
commit
8fbd7f3516
@ -121,15 +121,6 @@ class MySQL {
|
||||
}
|
||||
|
||||
// Images
|
||||
public function getTotalImages() {
|
||||
|
||||
$query = $this->_db->prepare('SELECT COUNT(*) AS `total` FROM `hostImage`');
|
||||
|
||||
$query->execute();
|
||||
|
||||
return $query->fetch()->total;
|
||||
}
|
||||
|
||||
public function getTotalHostImages(int $hostId) {
|
||||
|
||||
$query = $this->_db->prepare('SELECT COUNT(*) AS `total` FROM `hostImage` WHERE `hostId` = ?');
|
||||
@ -362,15 +353,6 @@ class MySQL {
|
||||
return $query->fetch()->total;
|
||||
}
|
||||
|
||||
public function getTotalPages() {
|
||||
|
||||
$query = $this->_db->prepare('SELECT COUNT(*) AS `total` FROM `hostPage`');
|
||||
|
||||
$query->execute();
|
||||
|
||||
return $query->fetch()->total;
|
||||
}
|
||||
|
||||
public function getHostPage(int $hostId, int $crc32uri) {
|
||||
|
||||
$query = $this->_db->prepare('SELECT * FROM `hostPage` WHERE `hostId` = ? AND `crc32uri` = ? LIMIT 1');
|
||||
|
@ -49,6 +49,15 @@ class SphinxQL {
|
||||
return $query->fetchAll();
|
||||
}
|
||||
|
||||
public function getHostPagesTotal() {
|
||||
|
||||
$query = $this->_sphinx->prepare('SELECT COUNT(*) AS `total` FROM `hostPage`');
|
||||
|
||||
$query->execute();
|
||||
|
||||
return $query->fetch()->total;
|
||||
}
|
||||
|
||||
public function searchHostPagesTotal(string $keyword) {
|
||||
|
||||
$query = $this->_sphinx->prepare('SELECT COUNT(*) AS `total` FROM `hostPage` WHERE MATCH(?)');
|
||||
@ -66,4 +75,13 @@ class SphinxQL {
|
||||
|
||||
return $query->fetch()->total;
|
||||
}
|
||||
|
||||
public function getHostImagesTotal() {
|
||||
|
||||
$query = $this->_sphinx->prepare('SELECT COUNT(*) AS `total` FROM `hostImage`');
|
||||
|
||||
$query->execute();
|
||||
|
||||
return $query->fetch()->total;
|
||||
}
|
||||
}
|
||||
|
@ -3,12 +3,12 @@
|
||||
// Load system dependencies
|
||||
require_once('../config/app.php');
|
||||
require_once('../library/filter.php');
|
||||
require_once('../library/mysql.php');
|
||||
require_once('../library/sphinxql.php');
|
||||
|
||||
// Connect database
|
||||
$db = new MySQL(DB_HOST, DB_PORT, DB_NAME, DB_USERNAME, DB_PASSWORD);
|
||||
// Connect Sphinx search server
|
||||
$sphinx = new SphinxQL(SPHINX_HOST, SPHINX_PORT);
|
||||
|
||||
$totalPages = $db->getTotalPages();
|
||||
$totalPages = $sphinx->getHostPagesTotal();
|
||||
|
||||
$placeholder = Filter::plural($totalPages, [sprintf(_('Over %s page or enter the new one...'), $totalPages),
|
||||
sprintf(_('Over %s pages or enter the new one...'), $totalPages),
|
||||
|
@ -26,7 +26,7 @@ switch ($t) {
|
||||
|
||||
case 'image':
|
||||
|
||||
$totalPages = $db->getTotalImages();
|
||||
$totalPages = $sphinx->getHostImagesTotal();
|
||||
|
||||
$placeholder = Filter::plural($totalPages, [sprintf(_('Over %s image or enter the new one...'), $totalPages),
|
||||
sprintf(_('Over %s images or enter the new one...'), $totalPages),
|
||||
@ -36,7 +36,7 @@ switch ($t) {
|
||||
break;
|
||||
default:
|
||||
|
||||
$totalPages = $db->getTotalPages();
|
||||
$totalPages = $sphinx->getHostPagesTotal();
|
||||
|
||||
$placeholder = Filter::plural($totalPages, [sprintf(_('Over %s page or enter the new one...'), $totalPages),
|
||||
sprintf(_('Over %s pages or enter the new one...'), $totalPages),
|
||||
|
Loading…
x
Reference in New Issue
Block a user