Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit 24b1fab

Browse files
1.10
* [*] больше проверок существования индексов * [*] функция, возвращающая номер версии мантикоры
1 parent cd7f1e1 commit 24b1fab

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

src/SphinxToolkit.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,18 @@ public function rebuildAbstractIndexMVA(string $mysql_table, string $sphinx_inde
157157
$sphinx_connection = $this->sphinx_connection;
158158

159159
$chunk_size = $this->rai_options['chunk_length'];
160-
161-
// проверяем, существует ли индекс
160+
161+
if (empty($sphinx_index))
162+
throw new Exception("SearchD index: `{$sphinx_index}` not defined", 1);
163+
164+
if (empty($mysql_table))
165+
throw new Exception("MySQL table: `{$mysql_table}` not defined", 1);
166+
162167
if (! SphinxToolkitHelper::RTIndexCheckExist($this->sphinx_connection, $sphinx_index))
163-
throw new Exception("`{$sphinx_index}` not present", 1);
168+
throw new Exception("SearchD index: `{$sphinx_index}` not found", 1);
169+
170+
if (! SphinxToolkitHelper::RTIndexCheckExist($this->mysql_connection, $mysql_table))
171+
throw new Exception("Source mysql table `{$mysql_table}` not found", 1);
164172

165173
// truncate
166174
SphinxToolkitHelper::RTIndexTruncate($sphinx_connection, $sphinx_index);

traits/SphinxToolkitHelper.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,18 @@ public static function showMeta(ConnectionInterface $connection)
249249
return (new Helper($connection))->showMeta()->execute()->fetchAllAssoc();
250250
}
251251

252+
/**
253+
* Возвращает версию поискового движка
254+
*
255+
* @param ConnectionInterface $connection
256+
* @throws \Foolz\SphinxQL\Exception\ConnectionException
257+
* @throws \Foolz\SphinxQL\Exception\DatabaseException
258+
*/
259+
public static function getVersion(ConnectionInterface $connection)
260+
{
261+
$connection->query("show status like 'version%'")->fetchAssoc()['version'];
262+
}
263+
252264

253265

254266
}

0 commit comments

Comments
 (0)