@@ -42,7 +42,6 @@ public function __construct(PDO $mysql_connection, PDO $sphinx_connection)
42
42
$ this ->sphinx_connection = $ sphinx_connection ;
43
43
}
44
44
45
-
46
45
public function setRebuildIndexOptions (array $ options = []):array
47
46
{
48
47
// на самом деле разворачиваем опции с установкой дефолтов
@@ -74,16 +73,16 @@ public function rebuildAbstractIndex(string $mysql_table, string $sphinx_index,
74
73
$ sphinx_connection = $ this ->sphinx_connection ;
75
74
76
75
// проверяем, существует ли индекс
77
- if (!$ this ->checkIndexExist ( $ sphinx_index ))
76
+ if (! SphinxToolkitHelper:: RTIndexCheckExist ( $ this ->sphinx_connection , $ sphinx_index ))
78
77
throw new Exception ("` {$ sphinx_index }` not present " , 1 );
79
78
80
79
$ chunk_size = $ this ->rai_options ['chunk_length ' ];
81
80
82
81
// truncate
83
- $ sphinx_connection-> query ( " TRUNCATE RTINDEX { $ sphinx_index} WITH RECONFIGURE " );
82
+ SphinxToolkitHelper:: RTIndexTruncate ( $ sphinx_connection, $ sphinx_index );
84
83
85
84
// get total count
86
- $ total_count = $ this -> mysql_GetRowCount ($ mysql_connection , $ mysql_table , $ condition );
85
+ $ total_count = SphinxToolkitHelper:: MySQL_GetRowsCount ($ mysql_connection , $ mysql_table , $ condition );
87
86
$ total_updated = 0 ;
88
87
89
88
if ($ this ->rai_options ['log_before_index ' ])
@@ -152,14 +151,14 @@ public function rebuildAbstractIndexMVA(string $mysql_table, string $sphinx_inde
152
151
$ chunk_size = $ this ->rai_options ['chunk_length ' ];
153
152
154
153
// проверяем, существует ли индекс
155
- if (!$ this ->checkIndexExist ( $ sphinx_index ))
154
+ if (! SphinxToolkitHelper:: RTIndexCheckExist ( $ this ->sphinx_connection , $ sphinx_index ))
156
155
throw new Exception ("` {$ sphinx_index }` not present " , 1 );
157
156
158
157
// truncate
159
- $ sphinx_connection-> query ( " TRUNCATE RTINDEX { $ sphinx_index} WITH RECONFIGURE " );
158
+ SphinxToolkitHelper:: RTIndexTruncate ( $ sphinx_connection, $ sphinx_index );
160
159
161
160
// get total count
162
- $ total_count = $ this -> mysql_GetRowCount ($ mysql_connection , $ mysql_table , $ condition );
161
+ $ total_count = SphinxToolkitHelper:: MySQL_GetRowsCount ($ mysql_connection , $ mysql_table , $ condition );
163
162
$ total_updated = 0 ;
164
163
165
164
if ($ this ->rai_options ['log_before_index ' ])
@@ -281,29 +280,15 @@ private static function buildReplaceQuery(string $table, array $dataset):string
281
280
return $ query ;
282
281
}
283
282
284
-
285
- /**
286
- * @param PDO $pdo
287
- * @param string $table
288
- * @param string $condition
289
- * @return int
290
- * @throws PDOException
291
- */
292
- private function mysql_GetRowCount (PDO $ pdo , string $ table , string $ condition )
293
- {
294
- $ query = "SELECT COUNT(*) AS cnt FROM {$ table }" ;
295
- if ($ condition != '' ) $ query .= " WHERE {$ condition }" ;
296
-
297
- return $ pdo ->query ($ query )->fetchColumn ();
298
- } // mysql_GetRowCount
299
-
300
283
public function checkIndexExist (string $ sphinx_index )
301
284
{
302
285
$ index_definition = $ this ->sphinx_connection ->query ("SHOW TABLES LIKE ' {$ sphinx_index }' " )->fetchAll ();
303
286
304
287
return count ($ index_definition ) > 0 ;
305
288
}
306
-
289
+
290
+
291
+
307
292
/* =========================== СТАТИЧЕСКИЕ МЕТОДЫ ==================================== */
308
293
309
294
public static function EmulateBuildExcerpts ($ source , $ needle , $ options )
0 commit comments