vendor/symfony/src/Symfony/Bundle/DoctrineBundle/Command/Proxy/RunSqlDoctrineCommand.php
changeset 0 7f95f8617b0b
equal deleted inserted replaced
-1:000000000000 0:7f95f8617b0b
       
     1 <?php
       
     2 
       
     3 /*
       
     4  * This file is part of the Symfony package.
       
     5  *
       
     6  * (c) Fabien Potencier <fabien@symfony.com>
       
     7  *
       
     8  * For the full copyright and license information, please view the LICENSE
       
     9  * file that was distributed with this source code.
       
    10  */
       
    11 
       
    12 namespace Symfony\Bundle\DoctrineBundle\Command\Proxy;
       
    13 
       
    14 use Symfony\Component\Console\Input\InputArgument;
       
    15 use Symfony\Component\Console\Input\InputOption;
       
    16 use Symfony\Component\Console\Input\InputInterface;
       
    17 use Symfony\Component\Console\Output\OutputInterface;
       
    18 use Symfony\Component\Console\Output\Output;
       
    19 use Doctrine\DBAL\Tools\Console\Command\RunSqlCommand;
       
    20 
       
    21 /**
       
    22  * Execute a SQL query and output the results.
       
    23  *
       
    24  * @author Fabien Potencier <fabien@symfony.com>
       
    25  * @author Jonathan H. Wage <jonwage@gmail.com>
       
    26  */
       
    27 class RunSqlDoctrineCommand extends RunSqlCommand
       
    28 {
       
    29     protected function configure()
       
    30     {
       
    31         parent::configure();
       
    32 
       
    33         $this
       
    34             ->setName('doctrine:query:sql')
       
    35             ->addOption('connection', null, InputOption::VALUE_OPTIONAL, 'The connection to use for this command')
       
    36             ->setHelp(<<<EOT
       
    37 The <info>doctrine:query:sql</info> command executes the given DQL query and
       
    38 outputs the results:
       
    39 
       
    40 <info>php app/console doctrine:query:sql "SELECT * from user"</info>
       
    41 EOT
       
    42         );
       
    43     }
       
    44 
       
    45     protected function execute(InputInterface $input, OutputInterface $output)
       
    46     {
       
    47         DoctrineCommandHelper::setApplicationConnection($this->getApplication(), $input->getOption('connection'));
       
    48 
       
    49         return parent::execute($input, $output);
       
    50     }
       
    51 }