@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | /** |
| 43 | 43 | * @var int|float |
| 44 | 44 | */ |
| 45 | - private $scanTimeOut=10; |
|
| 45 | + private $scanTimeOut = 10; |
|
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | 48 | * @var array |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | * |
| 78 | 78 | * @var array |
| 79 | 79 | */ |
| 80 | - private $_table_size_cache=[]; |
|
| 80 | + private $_table_size_cache = []; |
|
| 81 | 81 | |
| 82 | 82 | /** |
| 83 | 83 | * Cluster constructor. |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | |
| 192 | 192 | // @todo : rewrite total_replicas=1 если кластер без реплики , нужно проверять какой класте и сколько в нем реплик |
| 193 | 193 | // if ($replica['total_replicas']<2) {$ok=false;$this->error[]='total_replicas : '.json_encode($replica);} |
| 194 | - if ($this->softCheck ) |
|
| 194 | + if ($this->softCheck) |
|
| 195 | 195 | { |
| 196 | 196 | if (!$ok) break; |
| 197 | 197 | continue; |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | $statementsClusters[$node]->getRequest()->setDnsCache(0)->timeOut($this->scanTimeOut)->connectTimeOut($this->scanTimeOut); |
| 263 | 263 | } |
| 264 | 264 | $this->defaultClient()->executeAsync(); |
| 265 | - $tables=[]; |
|
| 265 | + $tables = []; |
|
| 266 | 266 | |
| 267 | 267 | foreach ($this->nodes as $node) { |
| 268 | 268 | |
@@ -270,16 +270,16 @@ discard block |
||
| 270 | 270 | try { |
| 271 | 271 | $r = $statementsReplicas[$node]->rows(); |
| 272 | 272 | foreach ($r as $row) { |
| 273 | - $tables[$row['database']][$row['table']][$node] =$row; |
|
| 273 | + $tables[$row['database']][$row['table']][$node] = $row; |
|
| 274 | 274 | } |
| 275 | 275 | $result['replicas'][$node] = $r; |
| 276 | - } catch (\Exception $E) { |
|
| 276 | + }catch (\Exception $E) { |
|
| 277 | 277 | $result['replicas'][$node] = false; |
| 278 | 278 | $badNodes[$node] = $E->getMessage(); |
| 279 | 279 | $this->error[] = 'statementsReplicas:' . $E->getMessage(); |
| 280 | 280 | } |
| 281 | 281 | // --------------------------------------------------------------------------------------------------- |
| 282 | - $hosts=[]; |
|
| 282 | + $hosts = []; |
|
| 283 | 283 | |
| 284 | 284 | try { |
| 285 | 285 | $c = $statementsClusters[$node]->rows(); |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | ]; |
| 296 | 296 | } |
| 297 | 297 | |
| 298 | - } catch (\Exception $E) { |
|
| 298 | + }catch (\Exception $E) { |
|
| 299 | 299 | $result['clusters'][$node] = false; |
| 300 | 300 | |
| 301 | 301 | $this->error[] = 'clusters:' . $E->getMessage(); |
@@ -363,22 +363,22 @@ discard block |
||
| 363 | 363 | * @return Client |
| 364 | 364 | * @throws Exception\TransportException |
| 365 | 365 | */ |
| 366 | - public function clientLike($cluster,$ip_addr_like) |
|
| 366 | + public function clientLike($cluster, $ip_addr_like) |
|
| 367 | 367 | { |
| 368 | - $nodes_check=$this->nodes; |
|
| 369 | - $nodes=$this->getClusterNodes($cluster); |
|
| 370 | - $list_ips_need=explode(';',$ip_addr_like); |
|
| 371 | - $find=false; |
|
| 372 | - foreach($list_ips_need as $like) |
|
| 368 | + $nodes_check = $this->nodes; |
|
| 369 | + $nodes = $this->getClusterNodes($cluster); |
|
| 370 | + $list_ips_need = explode(';', $ip_addr_like); |
|
| 371 | + $find = false; |
|
| 372 | + foreach ($list_ips_need as $like) |
|
| 373 | 373 | { |
| 374 | 374 | foreach ($nodes as $node) |
| 375 | 375 | { |
| 376 | 376 | |
| 377 | - if (stripos($node,$like)!==false) |
|
| 377 | + if (stripos($node, $like) !== false) |
|
| 378 | 378 | { |
| 379 | - if (in_array($node,$nodes_check)) |
|
| 379 | + if (in_array($node, $nodes_check)) |
|
| 380 | 380 | { |
| 381 | - $find=$node; |
|
| 381 | + $find = $node; |
|
| 382 | 382 | } |
| 383 | 383 | else |
| 384 | 384 | { |
@@ -390,8 +390,8 @@ discard block |
||
| 390 | 390 | } |
| 391 | 391 | if ($find) break; |
| 392 | 392 | } |
| 393 | - if (!$find){ |
|
| 394 | - $find=$nodes[0]; |
|
| 393 | + if (!$find) { |
|
| 394 | + $find = $nodes[0]; |
|
| 395 | 395 | } |
| 396 | 396 | return $this->client($find); |
| 397 | 397 | } |
@@ -471,10 +471,10 @@ discard block |
||
| 471 | 471 | * @return array |
| 472 | 472 | * @throws Exception\TransportException |
| 473 | 473 | */ |
| 474 | - public function getTables($resultDetail=false) |
|
| 474 | + public function getTables($resultDetail = false) |
|
| 475 | 475 | { |
| 476 | 476 | $this->connect(); |
| 477 | - $list=[]; |
|
| 477 | + $list = []; |
|
| 478 | 478 | foreach ($this->tables as $db_name=>$tables) |
| 479 | 479 | { |
| 480 | 480 | foreach ($tables as $table_name=>$nodes) |
@@ -482,11 +482,11 @@ discard block |
||
| 482 | 482 | |
| 483 | 483 | if ($resultDetail) |
| 484 | 484 | { |
| 485 | - $list[$db_name.'.'.$table_name]=$nodes; |
|
| 485 | + $list[$db_name . '.' . $table_name] = $nodes; |
|
| 486 | 486 | } |
| 487 | 487 | else |
| 488 | 488 | { |
| 489 | - $list[$db_name.'.'.$table_name]=array_keys($nodes); |
|
| 489 | + $list[$db_name . '.' . $table_name] = array_keys($nodes); |
|
| 490 | 490 | } |
| 491 | 491 | } |
| 492 | 492 | } |
@@ -503,23 +503,23 @@ discard block |
||
| 503 | 503 | */ |
| 504 | 504 | public function getSizeTable($database_table) |
| 505 | 505 | { |
| 506 | - $nodes=$this->getNodesByTable($database_table); |
|
| 506 | + $nodes = $this->getNodesByTable($database_table); |
|
| 507 | 507 | // scan need node`s |
| 508 | 508 | foreach ($nodes as $node) |
| 509 | 509 | { |
| 510 | 510 | if (empty($this->_table_size_cache[$node])) |
| 511 | 511 | { |
| 512 | - $this->_table_size_cache[$node]=$this->client($node)->tablesSize(true); |
|
| 512 | + $this->_table_size_cache[$node] = $this->client($node)->tablesSize(true); |
|
| 513 | 513 | } |
| 514 | 514 | } |
| 515 | 515 | |
| 516 | - $sizes=[]; |
|
| 516 | + $sizes = []; |
|
| 517 | 517 | foreach ($this->_table_size_cache as $node=>$rows) |
| 518 | 518 | { |
| 519 | 519 | foreach ($rows as $row) |
| 520 | 520 | { |
| 521 | - $sizes[$row['database'].'.'.$row['table']][$node]=$row; |
|
| 522 | - @$sizes[$row['database'].'.'.$row['table']]['total']['sizebytes']+=$row['sizebytes']; |
|
| 521 | + $sizes[$row['database'] . '.' . $row['table']][$node] = $row; |
|
| 522 | + @$sizes[$row['database'] . '.' . $row['table']]['total']['sizebytes'] += $row['sizebytes']; |
|
| 523 | 523 | |
| 524 | 524 | |
| 525 | 525 | |
@@ -541,17 +541,17 @@ discard block |
||
| 541 | 541 | * @return array |
| 542 | 542 | * @throws Exception\TransportException |
| 543 | 543 | */ |
| 544 | - public function truncateTable($database_table,$timeOut=2000) |
|
| 544 | + public function truncateTable($database_table, $timeOut = 2000) |
|
| 545 | 545 | { |
| 546 | - $out=[]; |
|
| 547 | - list($db,$table)=explode('.',$database_table); |
|
| 548 | - $nodes=$this->getMasterNodeForTable($database_table); |
|
| 546 | + $out = []; |
|
| 547 | + list($db, $table) = explode('.', $database_table); |
|
| 548 | + $nodes = $this->getMasterNodeForTable($database_table); |
|
| 549 | 549 | // scan need node`s |
| 550 | 550 | foreach ($nodes as $node) |
| 551 | 551 | { |
| 552 | - $def=$this->client($node)->getTimeout(); |
|
| 552 | + $def = $this->client($node)->getTimeout(); |
|
| 553 | 553 | $this->client($node)->database($db)->setTimeout($timeOut); |
| 554 | - $out[$node]=$this->client($node)->truncateTable($table); |
|
| 554 | + $out[$node] = $this->client($node)->truncateTable($table); |
|
| 555 | 555 | $this->client($node)->setTimeout($def); |
| 556 | 556 | } |
| 557 | 557 | return $out; |
@@ -566,15 +566,15 @@ discard block |
||
| 566 | 566 | */ |
| 567 | 567 | public function getMasterNodeForTable($database_table) |
| 568 | 568 | { |
| 569 | - $list=$this->getTables(true); |
|
| 569 | + $list = $this->getTables(true); |
|
| 570 | 570 | |
| 571 | 571 | if (empty($list[$database_table])) return []; |
| 572 | 572 | |
| 573 | 573 | |
| 574 | - $result=[]; |
|
| 574 | + $result = []; |
|
| 575 | 575 | foreach ($list[$database_table] as $node=>$row) |
| 576 | 576 | { |
| 577 | - if ($row['is_leader']) $result[]=$node; |
|
| 577 | + if ($row['is_leader']) $result[] = $node; |
|
| 578 | 578 | } |
| 579 | 579 | return $result; |
| 580 | 580 | } |
@@ -587,7 +587,7 @@ discard block |
||
| 587 | 587 | */ |
| 588 | 588 | public function getNodesByTable($database_table) |
| 589 | 589 | { |
| 590 | - $list=$this->getTables(); |
|
| 590 | + $list = $this->getTables(); |
|
| 591 | 591 | if (empty($list[$database_table])) { |
| 592 | 592 | throw new QueryException('Not find :' . $database_table); |
| 593 | 593 | } |
@@ -39,11 +39,11 @@ discard block |
||
| 39 | 39 | /** |
| 40 | 40 | * @var bool |
| 41 | 41 | */ |
| 42 | - private $_connect_user_readonly=false; |
|
| 42 | + private $_connect_user_readonly = false; |
|
| 43 | 43 | /** |
| 44 | 44 | * @var array |
| 45 | 45 | */ |
| 46 | - private $_support_format=['TabSeparated','TabSeparatedWithNames','CSV','CSVWithNames','JSONEachRow']; |
|
| 46 | + private $_support_format = ['TabSeparated', 'TabSeparatedWithNames', 'CSV', 'CSVWithNames', 'JSONEachRow']; |
|
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | 49 | * Client constructor. |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | public function setReadOnlyUser($flag) |
| 122 | 122 | { |
| 123 | - $this->_connect_user_readonly=$flag; |
|
| 123 | + $this->_connect_user_readonly = $flag; |
|
| 124 | 124 | $this->settings()->setReadOnlyUser($this->_connect_user_readonly); |
| 125 | 125 | } |
| 126 | 126 | /** |
@@ -163,10 +163,10 @@ discard block |
||
| 163 | 163 | |
| 164 | 164 | if (is_array($host)) |
| 165 | 165 | { |
| 166 | - $host=array_rand(array_flip($host)); |
|
| 166 | + $host = array_rand(array_flip($host)); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - $this->_connect_host=$host; |
|
| 169 | + $this->_connect_host = $host; |
|
| 170 | 170 | $this->transport()->setHost($host); |
| 171 | 171 | } |
| 172 | 172 | |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | /** |
| 290 | 290 | * @return $this |
| 291 | 291 | */ |
| 292 | - public function useSession($useSessionId=false) |
|
| 292 | + public function useSession($useSessionId = false) |
|
| 293 | 293 | { |
| 294 | 294 | if (!$this->settings()->getSessionId()) |
| 295 | 295 | { |
@@ -346,7 +346,7 @@ discard block |
||
| 346 | 346 | */ |
| 347 | 347 | public function enableLogQueries($flag = true) |
| 348 | 348 | { |
| 349 | - $this->settings()->set('log_queries',intval($flag)); |
|
| 349 | + $this->settings()->set('log_queries', intval($flag)); |
|
| 350 | 350 | return $this; |
| 351 | 351 | } |
| 352 | 352 | |
@@ -368,7 +368,7 @@ discard block |
||
| 368 | 368 | * @param bool $flag |
| 369 | 369 | * @return $this |
| 370 | 370 | */ |
| 371 | - public function https($flag=true) |
|
| 371 | + public function https($flag = true) |
|
| 372 | 372 | { |
| 373 | 373 | $this->settings()->https($flag); |
| 374 | 374 | return $this; |
@@ -382,7 +382,7 @@ discard block |
||
| 382 | 382 | */ |
| 383 | 383 | public function enableExtremes($flag = true) |
| 384 | 384 | { |
| 385 | - $this->settings()->set('extremes',intval($flag)); |
|
| 385 | + $this->settings()->set('extremes', intval($flag)); |
|
| 386 | 386 | return $this; |
| 387 | 387 | } |
| 388 | 388 | |
@@ -397,9 +397,9 @@ discard block |
||
| 397 | 397 | * @throws Exception\TransportException |
| 398 | 398 | * @throws \Exception |
| 399 | 399 | */ |
| 400 | - public function select($sql, $bindings = [], $whereInFile = null, $writeToFile=null) |
|
| 400 | + public function select($sql, $bindings = [], $whereInFile = null, $writeToFile = null) |
|
| 401 | 401 | { |
| 402 | - return $this->transport()->select($sql, $bindings, $whereInFile,$writeToFile); |
|
| 402 | + return $this->transport()->select($sql, $bindings, $whereInFile, $writeToFile); |
|
| 403 | 403 | } |
| 404 | 404 | |
| 405 | 405 | /** |
@@ -446,9 +446,9 @@ discard block |
||
| 446 | 446 | * @throws Exception\TransportException |
| 447 | 447 | * @throws \Exception |
| 448 | 448 | */ |
| 449 | - public function selectAsync($sql, $bindings = [], $whereInFile = null,$writeToFile=null) |
|
| 449 | + public function selectAsync($sql, $bindings = [], $whereInFile = null, $writeToFile = null) |
|
| 450 | 450 | { |
| 451 | - return $this->transport()->selectAsync($sql, $bindings, $whereInFile,$writeToFile); |
|
| 451 | + return $this->transport()->selectAsync($sql, $bindings, $whereInFile, $writeToFile); |
|
| 452 | 452 | } |
| 453 | 453 | |
| 454 | 454 | /** |
@@ -485,7 +485,7 @@ discard block |
||
| 485 | 485 | */ |
| 486 | 486 | public function showCreateTable($table) |
| 487 | 487 | { |
| 488 | - return ($this->select('SHOW CREATE TABLE '.$table)->fetchOne('statement')); |
|
| 488 | + return ($this->select('SHOW CREATE TABLE ' . $table)->fetchOne('statement')); |
|
| 489 | 489 | } |
| 490 | 490 | |
| 491 | 491 | /** |
@@ -545,17 +545,17 @@ discard block |
||
| 545 | 545 | */ |
| 546 | 546 | public function prepareInsertAssocBulk(array $values) |
| 547 | 547 | { |
| 548 | - if (isset($values[0]) && is_array($values[0])){ //случай, когда много строк вставляется |
|
| 548 | + if (isset($values[0]) && is_array($values[0])) { //случай, когда много строк вставляется |
|
| 549 | 549 | $preparedFields = array_keys($values[0]); |
| 550 | 550 | $preparedValues = []; |
| 551 | - foreach ($values as $idx => $row){ |
|
| 551 | + foreach ($values as $idx => $row) { |
|
| 552 | 552 | $_fields = array_keys($row); |
| 553 | - if ($_fields !== $preparedFields){ |
|
| 554 | - throw new QueryException("Fields not match: ".implode(',',$_fields)." and ".implode(',', $preparedFields)." on element $idx"); |
|
| 553 | + if ($_fields !== $preparedFields) { |
|
| 554 | + throw new QueryException("Fields not match: " . implode(',', $_fields) . " and " . implode(',', $preparedFields) . " on element $idx"); |
|
| 555 | 555 | } |
| 556 | 556 | $preparedValues[] = array_values($row); |
| 557 | 557 | } |
| 558 | - }else{ //одна строка |
|
| 558 | + } else { //одна строка |
|
| 559 | 559 | $preparedFields = array_keys($values); |
| 560 | 560 | $preparedValues = [array_values($values)]; |
| 561 | 561 | } |
@@ -588,7 +588,7 @@ discard block |
||
| 588 | 588 | */ |
| 589 | 589 | public function insertBatchTSVFiles($table_name, $file_names, $columns_array) |
| 590 | 590 | { |
| 591 | - return $this->insertBatchFiles($table_name,$file_names,$columns_array,'TabSeparated'); |
|
| 591 | + return $this->insertBatchFiles($table_name, $file_names, $columns_array, 'TabSeparated'); |
|
| 592 | 592 | } |
| 593 | 593 | |
| 594 | 594 | /** |
@@ -601,17 +601,17 @@ discard block |
||
| 601 | 601 | * @return array |
| 602 | 602 | * @throws Exception\TransportException |
| 603 | 603 | */ |
| 604 | - public function insertBatchFiles($table_name, $file_names, $columns_array,$format="CSV") |
|
| 604 | + public function insertBatchFiles($table_name, $file_names, $columns_array, $format = "CSV") |
|
| 605 | 605 | { |
| 606 | 606 | if (is_string($file_names)) |
| 607 | 607 | { |
| 608 | - $file_names=[$file_names]; |
|
| 608 | + $file_names = [$file_names]; |
|
| 609 | 609 | } |
| 610 | 610 | if ($this->getCountPendingQueue() > 0) { |
| 611 | 611 | throw new QueryException('Queue must be empty, before insertBatch, need executeAsync'); |
| 612 | 612 | } |
| 613 | 613 | |
| 614 | - if (!in_array($format,$this->_support_format)) |
|
| 614 | + if (!in_array($format, $this->_support_format)) |
|
| 615 | 615 | { |
| 616 | 616 | throw new QueryException('Format not support in insertBatchFiles'); |
| 617 | 617 | } |
@@ -620,17 +620,17 @@ discard block |
||
| 620 | 620 | |
| 621 | 621 | foreach ($file_names as $fileName) { |
| 622 | 622 | if (!is_file($fileName) || !is_readable($fileName)) { |
| 623 | - throw new QueryException('Cant read file: ' . $fileName.' '.(is_file($fileName)?'':' is not file')); |
|
| 623 | + throw new QueryException('Cant read file: ' . $fileName . ' ' . (is_file($fileName) ? '' : ' is not file')); |
|
| 624 | 624 | } |
| 625 | 625 | |
| 626 | 626 | if (!$columns_array) |
| 627 | 627 | { |
| 628 | - $sql = 'INSERT INTO ' . $table_name . ' FORMAT '.$format; |
|
| 628 | + $sql = 'INSERT INTO ' . $table_name . ' FORMAT ' . $format; |
|
| 629 | 629 | |
| 630 | 630 | } |
| 631 | 631 | else |
| 632 | 632 | { |
| 633 | - $sql = 'INSERT INTO ' . $table_name . ' ( ' . implode(',', $columns_array) . ' ) FORMAT '.$format; |
|
| 633 | + $sql = 'INSERT INTO ' . $table_name . ' ( ' . implode(',', $columns_array) . ' ) FORMAT ' . $format; |
|
| 634 | 634 | |
| 635 | 635 | } |
| 636 | 636 | $result[$fileName] = $this->transport()->writeAsyncCSV($sql, $fileName); |
@@ -657,25 +657,25 @@ discard block |
||
| 657 | 657 | * @param string $format ['TabSeparated','TabSeparatedWithNames','CSV','CSVWithNames'] |
| 658 | 658 | * @return Transport\CurlerRequest |
| 659 | 659 | */ |
| 660 | - public function insertBatchStream($table_name, $columns_array,$format="CSV") |
|
| 660 | + public function insertBatchStream($table_name, $columns_array, $format = "CSV") |
|
| 661 | 661 | { |
| 662 | 662 | if ($this->getCountPendingQueue() > 0) { |
| 663 | 663 | throw new QueryException('Queue must be empty, before insertBatch, need executeAsync'); |
| 664 | 664 | } |
| 665 | 665 | |
| 666 | - if (!in_array($format,$this->_support_format)) |
|
| 666 | + if (!in_array($format, $this->_support_format)) |
|
| 667 | 667 | { |
| 668 | 668 | throw new QueryException('Format not support in insertBatchFiles'); |
| 669 | 669 | } |
| 670 | 670 | |
| 671 | 671 | if (!$columns_array) |
| 672 | 672 | { |
| 673 | - $sql = 'INSERT INTO ' . $table_name . ' FORMAT '.$format; |
|
| 673 | + $sql = 'INSERT INTO ' . $table_name . ' FORMAT ' . $format; |
|
| 674 | 674 | |
| 675 | 675 | } |
| 676 | 676 | else |
| 677 | 677 | { |
| 678 | - $sql = 'INSERT INTO ' . $table_name . ' ( ' . implode(',', $columns_array) . ' ) FORMAT '.$format; |
|
| 678 | + $sql = 'INSERT INTO ' . $table_name . ' ( ' . implode(',', $columns_array) . ' ) FORMAT ' . $format; |
|
| 679 | 679 | |
| 680 | 680 | } |
| 681 | 681 | |
@@ -742,9 +742,9 @@ discard block |
||
| 742 | 742 | * @throws Exception\TransportException |
| 743 | 743 | * @throws \Exception |
| 744 | 744 | */ |
| 745 | - public function tablesSize($flatList=false) |
|
| 745 | + public function tablesSize($flatList = false) |
|
| 746 | 746 | { |
| 747 | - $z=$this->select(' |
|
| 747 | + $z = $this->select(' |
|
| 748 | 748 | SELECT name as table,database, |
| 749 | 749 | max(sizebytes) as sizebytes, |
| 750 | 750 | max(size) as size, |
@@ -764,7 +764,7 @@ discard block |
||
| 764 | 764 | ) USING ( table,database ) |
| 765 | 765 | WHERE database=:database |
| 766 | 766 | GROUP BY table,database |
| 767 | - ', [ 'database'=>$this->settings()->getDatabase() ]); |
|
| 767 | + ', ['database'=>$this->settings()->getDatabase()]); |
|
| 768 | 768 | |
| 769 | 769 | if ($flatList) { |
| 770 | 770 | return $z->rows(); |
@@ -786,12 +786,12 @@ discard block |
||
| 786 | 786 | * @throws Exception\TransportException |
| 787 | 787 | * @throws \Exception |
| 788 | 788 | */ |
| 789 | - public function isExists($database,$table) |
|
| 789 | + public function isExists($database, $table) |
|
| 790 | 790 | { |
| 791 | 791 | return $this->select(' |
| 792 | 792 | SELECT * |
| 793 | 793 | FROM system.tables |
| 794 | - WHERE name=\''.$table.'\' AND database=\''.$database.'\'' |
|
| 794 | + WHERE name=\''.$table . '\' AND database=\'' . $database . '\'' |
|
| 795 | 795 | )->rowsAsTree('name'); |
| 796 | 796 | } |
| 797 | 797 | |
@@ -810,7 +810,7 @@ discard block |
||
| 810 | 810 | return $this->select(' |
| 811 | 811 | SELECT * |
| 812 | 812 | FROM system.parts |
| 813 | - WHERE like(table,\'%' . $table . '%\') AND database=\''.$this->settings()->getDatabase().'\' |
|
| 813 | + WHERE like(table,\'%' . $table . '%\') AND database=\'' . $this->settings()->getDatabase() . '\' |
|
| 814 | 814 | ORDER BY max_date ' . ($limit > 0 ? ' LIMIT ' . intval($limit) : '') |
| 815 | 815 | )->rowsAsTree('name'); |
| 816 | 816 | } |
@@ -826,8 +826,8 @@ discard block |
||
| 826 | 826 | public function dropPartition($dataBaseTableName, $partition_id) |
| 827 | 827 | { |
| 828 | 828 | |
| 829 | - $partition_id=trim($partition_id,'\''); |
|
| 830 | - $this->settings()->set('replication_alter_partitions_sync',2); |
|
| 829 | + $partition_id = trim($partition_id, '\''); |
|
| 830 | + $this->settings()->set('replication_alter_partitions_sync', 2); |
|
| 831 | 831 | $state = $this->write('ALTER TABLE {dataBaseTableName} DROP PARTITION :partion_id', [ |
| 832 | 832 | 'dataBaseTableName' => $dataBaseTableName, |
| 833 | 833 | 'partion_id' => $partition_id |
@@ -845,12 +845,12 @@ discard block |
||
| 845 | 845 | */ |
| 846 | 846 | public function truncateTable($tableName) |
| 847 | 847 | { |
| 848 | - $partions=$this->partitions($tableName); |
|
| 849 | - $out=[]; |
|
| 848 | + $partions = $this->partitions($tableName); |
|
| 849 | + $out = []; |
|
| 850 | 850 | foreach ($partions as $part_key=>$part) |
| 851 | 851 | { |
| 852 | - $part_id=$part['partition']; |
|
| 853 | - $out[$part_id]=$this->dropPartition($tableName,$part_id); |
|
| 852 | + $part_id = $part['partition']; |
|
| 853 | + $out[$part_id] = $this->dropPartition($tableName, $part_id); |
|
| 854 | 854 | } |
| 855 | 855 | return $out; |
| 856 | 856 | } |
@@ -885,9 +885,9 @@ discard block |
||
| 885 | 885 | } |
| 886 | 886 | } |
| 887 | 887 | |
| 888 | - $result=[]; |
|
| 888 | + $result = []; |
|
| 889 | 889 | foreach ($drop as $partition_id) { |
| 890 | - $result[$partition_id]=$this->dropPartition($table_name, $partition_id); |
|
| 890 | + $result[$partition_id] = $this->dropPartition($table_name, $partition_id); |
|
| 891 | 891 | } |
| 892 | 892 | |
| 893 | 893 | return $result; |