From 24b1fab414f6acb94ee2fe5b286b615d05257f0e Mon Sep 17 00:00:00 2001 From: Karel Wintersky Date: Fri, 13 Nov 2020 12:10:46 +0300 Subject: [PATCH] 1.10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [*] больше проверок существования индексов * [*] функция, возвращающая номер версии мантикоры --- src/SphinxToolkit.php | 14 +++++++++++--- traits/SphinxToolkitHelper.php | 12 ++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/SphinxToolkit.php b/src/SphinxToolkit.php index 536b36b..5407f97 100644 --- a/src/SphinxToolkit.php +++ b/src/SphinxToolkit.php @@ -157,10 +157,18 @@ public function rebuildAbstractIndexMVA(string $mysql_table, string $sphinx_inde $sphinx_connection = $this->sphinx_connection; $chunk_size = $this->rai_options['chunk_length']; - - // проверяем, существует ли индекс + + if (empty($sphinx_index)) + throw new Exception("SearchD index: `{$sphinx_index}` not defined", 1); + + if (empty($mysql_table)) + throw new Exception("MySQL table: `{$mysql_table}` not defined", 1); + if (! SphinxToolkitHelper::RTIndexCheckExist($this->sphinx_connection, $sphinx_index)) - throw new Exception("`{$sphinx_index}` not present", 1); + throw new Exception("SearchD index: `{$sphinx_index}` not found", 1); + + if (! SphinxToolkitHelper::RTIndexCheckExist($this->mysql_connection, $mysql_table)) + throw new Exception("Source mysql table `{$mysql_table}` not found", 1); // truncate SphinxToolkitHelper::RTIndexTruncate($sphinx_connection, $sphinx_index); diff --git a/traits/SphinxToolkitHelper.php b/traits/SphinxToolkitHelper.php index a81f0fa..e91e015 100644 --- a/traits/SphinxToolkitHelper.php +++ b/traits/SphinxToolkitHelper.php @@ -249,6 +249,18 @@ public static function showMeta(ConnectionInterface $connection) return (new Helper($connection))->showMeta()->execute()->fetchAllAssoc(); } + /** + * Возвращает версию поискового движка + * + * @param ConnectionInterface $connection + * @throws \Foolz\SphinxQL\Exception\ConnectionException + * @throws \Foolz\SphinxQL\Exception\DatabaseException + */ + public static function getVersion(ConnectionInterface $connection) + { + $connection->query("show status like 'version%'")->fetchAssoc()['version']; + } + } \ No newline at end of file