@@ 641-664 (lines=24) @@ | ||
638 | * @param string $viewName Name of view to export |
|
639 | * @return null |
|
640 | */ |
|
641 | private function getViewStructureTable($viewName) |
|
642 | { |
|
643 | if (!$this->dumpSettings['skip-comments']) { |
|
644 | $ret = "--" . PHP_EOL . |
|
645 | "-- Stand-In structure for view `${viewName}`" . PHP_EOL . |
|
646 | "--" . PHP_EOL . PHP_EOL; |
|
647 | $this->compressManager->write($ret); |
|
648 | } |
|
649 | $stmt = $this->typeAdapter->show_create_view($viewName); |
|
650 | ||
651 | // create views as tables, to resolve dependencies |
|
652 | foreach ($this->dbHandler->query($stmt) as $r) { |
|
653 | if ($this->dumpSettings['add-drop-table']) { |
|
654 | $this->compressManager->write( |
|
655 | $this->typeAdapter->drop_view($viewName) |
|
656 | ); |
|
657 | } |
|
658 | ||
659 | $this->compressManager->write( |
|
660 | $this->createStandInTable($viewName) |
|
661 | ); |
|
662 | break; |
|
663 | } |
|
664 | } |
|
665 | ||
666 | /** |
|
667 | * Write a create table statement for the table Stand-In, show create |
|
@@ 693-715 (lines=23) @@ | ||
690 | * @param string $viewName Name of view to export |
|
691 | * @return null |
|
692 | */ |
|
693 | private function getViewStructureView($viewName) |
|
694 | { |
|
695 | if (!$this->dumpSettings['skip-comments']) { |
|
696 | $ret = "--" . PHP_EOL . |
|
697 | "-- View structure for view `${viewName}`" . PHP_EOL . |
|
698 | "--" . PHP_EOL . PHP_EOL; |
|
699 | $this->compressManager->write($ret); |
|
700 | } |
|
701 | $stmt = $this->typeAdapter->show_create_view($viewName); |
|
702 | ||
703 | // create views, to resolve dependencies |
|
704 | // replacing tables with views |
|
705 | foreach ($this->dbHandler->query($stmt) as $r) { |
|
706 | // because we must replace table with view, we should delete it |
|
707 | $this->compressManager->write( |
|
708 | $this->typeAdapter->drop_view($viewName) |
|
709 | ); |
|
710 | $this->compressManager->write( |
|
711 | $this->typeAdapter->create_view($r) |
|
712 | ); |
|
713 | break; |
|
714 | } |
|
715 | } |
|
716 | ||
717 | /** |
|
718 | * Trigger structure extractor |