Fixes to sandbox and added printing of params to output of dql task.
This commit is contained in:
parent
00195ebb7d
commit
ddefc7f96d
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
Doctrine_Manager::getInstance()->setAttribute(Doctrine::ATTR_MODEL_LOADING, Doctrine::MODEL_LOADING_CONSERVATIVE);
|
||||
|
Loading…
Reference in New Issue
Block a user