Esempio n. 1
0
 /**
  * Run arbitrary DQL and display results
  *
  * Any DQL queries passed after the parameters will be executed, the results will be output:
  *
  * doctrine:dql --limit 10 'SELECT a FROM TYPO3\FLOW3\Security\Account a'
  *
  * @param integer $depth How many levels deep the result should be dumped
  * @param string $hydrationMode One of: object, array, scalar, single-scalar, simpleobject
  * @param integer $offset Offset the result by this number
  * @param integer $limit Limit the result to this number
  * @return void
  * @throws \InvalidArgumentException
  */
 public function dqlCommand($depth = 3, $hydrationMode = 'array', $offset = NULL, $limit = NULL)
 {
     // "driver" is used only for Doctrine, thus we (mis-)use it here
     // additionally, when no path is set, skip this step, assuming no DB is needed
     if ($this->settings['backendOptions']['driver'] !== NULL && $this->settings['backendOptions']['host'] !== NULL) {
         $dqlStatements = $this->request->getExceedingArguments();
         $hydrationModeConstant = 'Doctrine\\ORM\\Query::HYDRATE_' . strtoupper(str_replace('-', '_', $hydrationMode));
         if (!defined($hydrationModeConstant)) {
             throw new \InvalidArgumentException('Hydration mode "' . $hydrationMode . '" does not exist. It should be either: object, array, scalar or single-scalar.');
         }
         foreach ($dqlStatements as $dql) {
             $resultSet = $this->doctrineService->runDql($dql, $hydrationModeConstant, $offset, $limit);
             \Doctrine\Common\Util\Debug::dump($resultSet, $depth);
         }
     } else {
         $this->outputLine('DQL query is not possible, the driver and host backend options are not set in /Configuration/Settings.yaml.');
         $this->quit(1);
     }
 }