Commit ddefc7f9 authored by jwage's avatar jwage

Fixes to sandbox and added printing of params to output of dql task.

parent 00195ebb
......@@ -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
}
......@@ -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);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment