https://github.com/arrisframework/sphinxql.pdo.wrapper
Arris µFramework SphinxQL PDO Wrapper
https://github.com/arrisframework/sphinxql.pdo.wrapper
arris manticoresearch pdo-wrapper searchd
Last synced: about 1 month ago
JSON representation
Arris µFramework SphinxQL PDO Wrapper
- Host: GitHub
- URL: https://github.com/arrisframework/sphinxql.pdo.wrapper
- Owner: ArrisFramework
- Created: 2024-09-09T22:51:50.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-10T01:28:39.000Z (over 1 year ago)
- Last Synced: 2025-03-25T17:06:47.165Z (11 months ago)
- Topics: arris, manticoresearch, pdo-wrapper, searchd
- Language: PHP
- Homepage: https://packagist.org/packages/karelwintersky/arris.toolkit.sphinxql-pdo-wrapper
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Arris µFramework SphinxQL PDO Wrapper
```php
use \Arris\Toolkit\SphinxQL\PDOWrapper;
$mysql_connection = new \Arris\Database\DBWrapper([
'driver' => 'mysql',
'hostname' => getenv('DB.HOST'),
'username' => getenv('DB.USERNAME'),
'password' => getenv('DB.PASSWORD'),
'database' => getenv('DB.NAME'),
'charset' => 'utf8',
'charset_collate' => 'utf8_general_ci',
'slow_query_threshold' => 1
]);
$sphinx_connection = new \Arris\Database\DBWrapper([
'driver' => 'mysql',
'hostname' => getenv('SEARCH.HOST'),
'database' => NULL,
'username' => getenv('SEARCH.USER'),
'password' => getenv('SEARCH.PASSWORD'),
'port' => getenv('SEARCH.PORT'),
'charset' => NULL,
'charset_collate' => NULL
]);
// или через Arris\Database\Connector()
$toolkit = new PDOWrapper($mysql_connection, $sphinx_connection);
$toolkit->setRebuildIndexOptions([
'log_rows_inside_chunk' => false,
'log_after_chunk' => false,
'sleep_after_chunk' => $options['is_sleep'],
'sleep_time' => $options['sleeptime'],
'chunk_length' => $options['sql_limit']
]);
$toolkit->setConsoleMessenger([ \Arris\Toolkit\CLIConsole::class, "say" ]);
$rt_index = getenv('SEARCH.RT_INDEX.ARTICLES');
if ($rt_index) {
// статьи
$count_rebuilt['articles'] =
$toolkit->rebuildAbstractIndex(
'articles',
$rt_index,
static function ($item) {
return \FSNews\SearchEngine::prepare_RTArticle($item, true);
},
" s_draft = 0 ",
true,
['rubrics', 'districts']
);
} else {
CLIConsole::say("[SEARCH.RT_INDEX.ARTICLES] disabled");
}
```
# ToDo
Добавить
```php
/**
* @param $connection
* @param $index
* @return false|\PDOStatement
*/
public static function RTIndexOptimize($connection, $index)
{
$query = "OPTIMIZE INDEX {$index}";
return $connection->query($query);
}
/**
* @param $connection
* @param $index
* @param bool $reconfigure
* @return bool
*/
public static function RTIndexTruncate($connection, $index, bool $reconfigure = true): bool
{
$with = $reconfigure ? 'WITH RECONFIGURE' : '';
return (bool)$connection->query("TRUNCATE RTINDEX {$index} {$with}");
}
/**
* @param $connection
* @param $index
* @return bool
*/
public static function RTIndexCheckExist($connection, $index)
{
$index_definition = $connection->query("SHOW TABLES LIKE '{$index}' ")->fetchAll();
return \count($index_definition) > 0;
}
// +show meta
// +show version
```