From 805af9b0009dd7e403c2298f0bb309a06e98c359 Mon Sep 17 00:00:00 2001 From: Karel Wintersky Date: Sat, 7 Nov 2020 14:28:42 +0300 Subject: [PATCH] 1.7.2 * [*] fix --- src/SphinxToolkit.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/SphinxToolkit.php b/src/SphinxToolkit.php index fe3bbc5..c707e5f 100644 --- a/src/SphinxToolkit.php +++ b/src/SphinxToolkit.php @@ -184,6 +184,10 @@ public function rebuildAbstractIndexMVA(string $mysql_table, string $sphinx_inde $query_chunk_data = " SELECT * FROM {$mysql_table} "; $query_chunk_data.= $condition != '' ? " WHERE {$condition} " : ''; $query_chunk_data.= " ORDER BY id DESC LIMIT {$offset}, {$chunk_size} "; + + /*$query_chunk_data = vsprintf("SELECT * FROM %s WHERE 1 = 1 %s ORDER BY id DESC LIMIT %s, %s", [ + $mysql_table, ($condition != '' ? " AND {$condition} " : ''), $offset, $chunk_size + ]);*/ $sth = $mysql_connection->query($query_chunk_data); @@ -469,13 +473,12 @@ public static function rt_RebuildAbstractIndex(PDO $pdo_connection, string $sql_ = $pdo_connection ->query("SELECT COUNT(*) as cnt FROM {$sql_source_table} " . ($condition != '' ? " WHERE {$condition} " : ' ') ) ->fetchColumn(); + $total_updated = 0; - if (self::$spql_options['log_before_index']) - CLIConsole::say("[{$sphinx_index}] index : ", false); + if (self::$spql_options['log_before_index']) CLIConsole::say("[{$sphinx_index}] index : ", false); - if (self::$spql_options['log_total_rows_found']) - CLIConsole::say("{$total_count} elements found for rebuild."); + if (self::$spql_options['log_total_rows_found']) CLIConsole::say("{$total_count} elements found for rebuild."); // iterate chunks for ($i = 0; $i < ceil($total_count / $chunk_size); $i++) { @@ -491,10 +494,9 @@ public static function rt_RebuildAbstractIndex(PDO $pdo_connection, string $sql_ // iterate inside chunk while ($item = $sth->fetch()) { - if (self::$spql_options['log_rows_inside_chunk']) - CLIConsole::say("{$sql_source_table}: {$item['id']}"); + if (self::$spql_options['log_rows_inside_chunk']) CLIConsole::say("{$sql_source_table}: {$item['id']}"); - $update_set = $make_updateset_method($item); + $update_set = $make_updateset_method($item); // call closure self::internal_ReplaceIndex($sphinx_index, $update_set); @@ -515,8 +517,8 @@ public static function rt_RebuildAbstractIndex(PDO $pdo_connection, string $sql_ CLIConsole::say("I woke up!"); } } // for - if (self::$spql_options['log_after_index']) - CLIConsole::say("Total updated {$total_updated} elements for {$sphinx_index} RT-index.
"); + + if (self::$spql_options['log_after_index']) CLIConsole::say("Total updated {$total_updated} elements for {$sphinx_index} RT-index.
"); return $total_updated; } @@ -539,7 +541,7 @@ private static function internal_ReplaceIndex(string $index_name, array $updates { if (empty($updateset)) return null; - return self::getInstance() + return self::getInstance(self::$spql_connection) ->replace() ->into($index_name) ->set($updateset)