|
0
|
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\ORM\Tools\Console\Command\RunDqlCommand; |
|
|
20 |
|
|
|
21 |
/** |
|
|
22 |
* Execute a Doctrine DQL query and output the results. |
|
|
23 |
* |
|
|
24 |
* @author Fabien Potencier <fabien@symfony.com> |
|
|
25 |
* @author Jonathan H. Wage <jonwage@gmail.com> |
|
|
26 |
*/ |
|
|
27 |
class RunDqlDoctrineCommand extends RunDqlCommand |
|
|
28 |
{ |
|
|
29 |
protected function configure() |
|
|
30 |
{ |
|
|
31 |
parent::configure(); |
|
|
32 |
|
|
|
33 |
$this |
|
|
34 |
->setName('doctrine:query:dql') |
|
|
35 |
->addOption('em', null, InputOption::VALUE_OPTIONAL, 'The entity manager to use for this command') |
|
|
36 |
->setHelp(<<<EOT |
|
|
37 |
The <info>doctrine:query:dql</info> command executes the given DQL query and |
|
|
38 |
outputs the results: |
|
|
39 |
|
|
|
40 |
<info>php app/console doctrine:query:dql "SELECT u FROM UserBundle:User u"</info> |
|
|
41 |
|
|
|
42 |
You can also optional specify some additional options like what type of |
|
|
43 |
hydration to use when executing the query: |
|
|
44 |
|
|
|
45 |
<info>php app/console doctrine:query:dql "SELECT u FROM UserBundle:User u" --hydrate=array</info> |
|
|
46 |
|
|
|
47 |
Additionally you can specify the first result and maximum amount of results to |
|
|
48 |
show: |
|
|
49 |
|
|
|
50 |
<info>php app/console doctrine:query:dql "SELECT u FROM UserBundle:User u" --first-result=0 --max-result=30</info> |
|
|
51 |
EOT |
|
|
52 |
); |
|
|
53 |
} |
|
|
54 |
|
|
|
55 |
protected function execute(InputInterface $input, OutputInterface $output) |
|
|
56 |
{ |
|
|
57 |
DoctrineCommandHelper::setApplicationEntityManager($this->getApplication(), $input->getOption('em')); |
|
|
58 |
|
|
|
59 |
return parent::execute($input, $output); |
|
|
60 |
} |
|
|
61 |
} |