diff --git a/.gitattributes b/.gitattributes index 29ba50b..1cfde31 100644 --- a/.gitattributes +++ b/.gitattributes @@ -7,4 +7,6 @@ /tests export-ignore /vendor export-ignore /docs/_deprecated export-ignore +/docs/_todo export-ignore + diff --git a/sources/DB.php b/sources/DB.php index a472aa9..a8ed0e3 100644 --- a/sources/DB.php +++ b/sources/DB.php @@ -31,8 +31,8 @@ public static function buildUpdateQuery(string $table, array $dataset = [], $whe public static function buildReplaceQuery(string $table, array $dataset):string; public static function buildReplaceQueryMVA(string $table, array $dataset, array $mva_attributes):array; - public static function makeInsertQuery($tablename, $dataset):string; - public static function makeUpdateQuery($tablename, $dataset, $where_condition = ''):string; + public static function makeInsertQuery($tablename, &$dataset):string; + public static function makeUpdateQuery($tablename, &$dataset, $where_condition = ''):string; public static function getRowCount($table, $suffix = NULL):int; public static function getRowCountConditional($table, $field = '*', $condition = '', $suffix = NULL):int; @@ -418,7 +418,7 @@ public static function makeInsertQuery($tablename, &$dataset):string * @param string $where_condition * @return bool|string */ - public static function makeUpdateQuery($tablename, $dataset, $where_condition = ''):string + public static function makeUpdateQuery($tablename, &$dataset, $where_condition = ''):string { $query = ''; $r = []; @@ -429,6 +429,12 @@ public static function makeUpdateQuery($tablename, $dataset, $where_condition = $query = "UPDATE `{$tablename}` SET"; foreach ($dataset as $index => $value) { + if (strtoupper(trim($value)) === 'NOW()') { + $set[] = "\r\n `{$index}` = NOW()"; + unset($dataset[ $index ]); + continue; + } + $r[] = "\r\n`{$index}` = :{$index}"; } diff --git a/sources/SphinxToolkit.php b/sources/SphinxToolkit.php index 31d51f2..bfcb41d 100644 --- a/sources/SphinxToolkit.php +++ b/sources/SphinxToolkit.php @@ -22,7 +22,6 @@ public static function EmulateBuildExcerpts($source, $needle, $options); use Closure; use PDO; -use Arris\CLIConsole; /** * Class SphinxToolkit @@ -111,16 +110,13 @@ public function setRebuildIndexOptions(array $options = []):array */ public function rebuildAbstractIndex(string $mysql_table, string $sphinx_index, Closure $make_updateset_method, string $condition = ''):int { - $mysql_connection = $this->mysql_connection; - $sphinx_connection = $this->sphinx_connection; - $chunk_size = $this->rai_options['chunk_length']; // truncate - $sphinx_connection->query("TRUNCATE RTINDEX {$sphinx_index} "); + $this->sphinx_connection->query("TRUNCATE RTINDEX {$sphinx_index} "); // get total count - $total_count = $this->mysql_GetRowCount($mysql_connection, $mysql_table, $condition); + $total_count = $this->mysql_GetRowCount($this->mysql_connection, $mysql_table, $condition); $total_updated = 0; if ($this->rai_options['log_before_index']) @@ -140,7 +136,7 @@ public function rebuildAbstractIndex(string $mysql_table, string $sphinx_index, $query_chunk_data.= $condition != '' ? " WHERE {$condition} " : ''; $query_chunk_data.= "ORDER BY id DESC LIMIT {$offset}, {$chunk_size} "; - $sth = $mysql_connection->query($query_chunk_data); + $sth = $this->mysql_connection->query($query_chunk_data); // iterate inside chunk while ($item = $sth->fetch()) { @@ -151,7 +147,7 @@ public function rebuildAbstractIndex(string $mysql_table, string $sphinx_index, $update_query = DB::buildReplaceQuery($sphinx_index, $update_set); - $update_statement = $sphinx_connection->prepare($update_query); + $update_statement = $this->sphinx_connection->prepare($update_query); $update_statement->execute($update_set); $total_updated++; } // while @@ -189,16 +185,13 @@ public function rebuildAbstractIndex(string $mysql_table, string $sphinx_index, */ public function rebuildAbstractIndexMVA(string $mysql_table, string $sphinx_index, Closure $make_updateset_method, string $condition = '', array $mva_indexes_list = []):int { - $mysql_connection = $this->mysql_connection; - $sphinx_connection = $this->sphinx_connection; - $chunk_size = $this->rai_options['chunk_length']; // truncate - $sphinx_connection->query("TRUNCATE RTINDEX {$sphinx_index} "); + $this->sphinx_connection->query("TRUNCATE RTINDEX {$sphinx_index} "); // get total count - $total_count = $this->mysql_GetRowCount($mysql_connection, $mysql_table, $condition); + $total_count = $this->mysql_GetRowCount($this->mysql_connection, $mysql_table, $condition); $total_updated = 0; if ($this->rai_options['log_before_index']) @@ -218,7 +211,7 @@ public function rebuildAbstractIndexMVA(string $mysql_table, string $sphinx_inde $query_chunk_data.= $condition != '' ? " WHERE {$condition} " : ''; $query_chunk_data.= "ORDER BY id DESC LIMIT {$offset}, {$chunk_size} "; - $sth = $mysql_connection->query($query_chunk_data); + $sth = $this->mysql_connection->query($query_chunk_data); // iterate inside chunk while ($item = $sth->fetch()) { @@ -229,7 +222,7 @@ public function rebuildAbstractIndexMVA(string $mysql_table, string $sphinx_inde list($update_query, $new_update_set) = DB::buildReplaceQueryMVA($sphinx_index, $update_set, $mva_indexes_list); - $update_statement = $sphinx_connection->prepare($update_query); + $update_statement = $this->sphinx_connection->prepare($update_query); $update_statement->execute($new_update_set); $total_updated++; } // while diff --git a/sources/Toolkit/NginxToolkit.php b/sources/Toolkit/NginxToolkit.php index 14ff547..68b4c47 100644 --- a/sources/Toolkit/NginxToolkit.php +++ b/sources/Toolkit/NginxToolkit.php @@ -86,14 +86,10 @@ public static function init($options = []) * DEBUG: очистка лога в случае, если установлена ENV -> NGINX::LOG_CACHE_CLEANING * * @param string $url - * @param string $levels - * @param string $cache_key * @return bool */ public static function clear_nginx_cache(string $url) { - $unlink_status = true; - if (self::$is_using_cache == 0) { return false; }