1 | <?php |
||
44 | class DatabaseCommand extends ContainerAwareCommand |
||
45 | { |
||
46 | use ContainerInjector; |
||
47 | |||
48 | protected function configure() |
||
49 | { |
||
50 | $this->setName('database'); |
||
51 | $this->setDescription('* Exemple with database'); |
||
52 | } |
||
53 | |||
54 | protected function execute(InputInterface $input, OutputInterface $output) |
||
55 | { |
||
56 | if (!class_exists('Doctrine\DBAL\Connection')) { |
||
57 | $output->write('You need to include "doctrine/dbal" package in your composer.json'); |
||
58 | |||
59 | return false; |
||
60 | } |
||
61 | |||
62 | $databaseTables = $this->getContainer()->get('database.connection')->query('SHOW TABLES')->fetchAll(); |
||
63 | |||
64 | $tableHelper = $this->getHelper('table'); |
||
65 | |||
66 | $tableHelper->setHeaders(['Table name']); |
||
67 | $tableHelper->setRows($databaseTables); |
||
68 | |||
69 | $tableHelper->render($output); |
||
70 | } |
||
71 | } |
||
72 | |||
84 |