Skip to content

Commit

Permalink
1.10
Browse files Browse the repository at this point in the history
* [*] больше проверок существования индексов
* [*] функция, возвращающая номер версии мантикоры
  • Loading branch information
KarelWintersky committed Nov 13, 2020
1 parent cd7f1e1 commit 24b1fab
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/SphinxToolkit.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 12 additions & 0 deletions traits/SphinxToolkitHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
}



}

0 comments on commit 24b1fab

Please sign in to comment.