karelwintersky / arris.toolkit.sphinxql-pdo-wrapper
Arris µFramework SphinxQL PDO Wrapper
0.99.1
2024-09-10 01:28 UTC
Requires
- php: ^7.4 | 8.*
- ext-pdo: *
- psr/log: *
README
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 ]); $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] <font color='red'>disabled</font>"); }