From ddefc7f96dc784048846dbdda6eb2ad037ce319c Mon Sep 17 00:00:00 2001 From: jwage Date: Fri, 25 Jan 2008 02:53:24 +0000 Subject: [PATCH] Fixes to sandbox and added printing of params to output of dql task. --- lib/Doctrine/Task/Dql.php | 28 +++++++++++++++------------- tools/sandbox/config.php | 2 +- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/lib/Doctrine/Task/Dql.php b/lib/Doctrine/Task/Dql.php index 225a43b14..72584be10 100644 --- a/lib/Doctrine/Task/Dql.php +++ b/lib/Doctrine/Task/Dql.php @@ -36,38 +36,40 @@ class Doctrine_Task_Dql extends Doctrine_Task $requiredArguments = array('models_path' => 'Specify path to your Doctrine_Record definitions.', 'dql_query' => 'Specify the complete dql query to execute.'), $optionalArguments = array('params' => 'Comma separated list of the params to replace the ? tokens in the dql'); - + public function execute() { Doctrine::loadModels($this->getArgument('models_path')); - + $dql = $this->getArgument('dql_query'); - + $query = new Doctrine_Query(); + + $params = explode(',', $this->getArgument('params')); + + $this->notify('executing: "' . $dql . '" (' . implode(', ', $params) . ')'); - $this->notify('executing: "' . $dql . '"'); - - $results = $query->query($dql, explode(',', $this->getArgument('params'))); - + $results = $query->query($dql, $params); + $this->printResults($results); } - + protected function printResults($data) { $array = $data->toArray(true); - + $yaml = Doctrine_Parser::dump($array, 'yml'); $lines = explode("\n", $yaml); - + unset($lines[0]); $lines[1] = $data->getTable()->getOption('name') . ':'; - + foreach ($lines as $yamlLine) { $line = trim($yamlLine); - + if ($line) { $this->notify($yamlLine); } } } -} \ No newline at end of file +} diff --git a/tools/sandbox/config.php b/tools/sandbox/config.php index 49be80d8e..6abbf714f 100644 --- a/tools/sandbox/config.php +++ b/tools/sandbox/config.php @@ -50,4 +50,4 @@ spl_autoload_register(array('Doctrine', 'autoload')); Doctrine_Manager::connection(DSN, 'sandbox'); -Doctrine_Manager::getInstance()->setAttribute(Doctrine::ATTR_MODEL_LOADING, Doctrine::MODEL_LOADING_CONSERVATIVE); \ No newline at end of file +Doctrine_Manager::getInstance()->setAttribute(Doctrine::ATTR_MODEL_LOADING, Doctrine::MODEL_LOADING_CONSERVATIVE);