GetListTables.php 968 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. declare(strict_types=1);
  7. namespace Magento\Backup\Model\ResourceModel\Table;
  8. use Magento\Framework\App\ResourceConnection;
  9. /**
  10. * Provides full list of tables in the database. This list excludes views, to allow different backup process.
  11. */
  12. class GetListTables
  13. {
  14. private const TABLE_TYPE = 'BASE TABLE';
  15. /**
  16. * @var ResourceConnection
  17. */
  18. private $resource;
  19. /**
  20. * @param ResourceConnection $resource
  21. */
  22. public function __construct(ResourceConnection $resource)
  23. {
  24. $this->resource = $resource;
  25. }
  26. /**
  27. * Get list of database tables excluding views.
  28. *
  29. * @return array
  30. */
  31. public function execute(): array
  32. {
  33. return $this->resource->getConnection('backup')->fetchCol(
  34. "SHOW FULL TABLES WHERE `Table_type` = ?",
  35. self::TABLE_TYPE
  36. );
  37. }
  38. }