1
0
mirror of synced 2024-12-13 22:56:04 +03:00
This commit is contained in:
zYne 2007-05-19 17:05:25 +00:00
parent bbe6f1c2ea
commit c9d9bf1905

View File

@ -65,7 +65,7 @@ class Doctrine_RawSql extends Doctrine_Hydrate
public function get($name) public function get($name)
{ {
if ( ! isset($this->parts[$name])) { if ( ! isset($this->parts[$name])) {
throw new Doctrine_RawSql_Exception('Unknown query part '.$name); throw new Doctrine_RawSql_Exception('Unknown query part ' . $name);
} }
return $this->parts[$name]; return $this->parts[$name];
} }
@ -135,26 +135,26 @@ class Doctrine_RawSql extends Doctrine_Hydrate
public function getQuery() public function getQuery()
{ {
foreach ($this->fields as $field) { foreach ($this->fields as $field) {
$e = explode(".", $field); $e = explode('.', $field);
if ( ! isset($e[1])) { if ( ! isset($e[1])) {
throw new Doctrine_RawSql_Exception("All selected fields in Sql query must be in format tableAlias.fieldName"); throw new Doctrine_RawSql_Exception('All selected fields in Sql query must be in format tableAlias.fieldName');
} }
if ( ! isset($this->tables[$e[0]])) { if ( ! isset($this->tables[$e[0]])) {
try { try {
$this->addComponent($e[0], ucwords($e[0])); $this->addComponent($e[0], ucwords($e[0]));
} catch(Doctrine_Exception $exception) { } catch(Doctrine_Exception $exception) {
throw new Doctrine_RawSql_Exception("The associated component for table alias $e[0] couldn't be found."); throw new Doctrine_RawSql_Exception('The associated component for table alias ' . $e[0] . ' couldn\'t be found.');
} }
} }
if ($e[1] == '*') { if ($e[1] == '*') {
foreach ($this->tables[$e[0]]->getColumnNames() as $name) { foreach ($this->tables[$e[0]]->getColumnNames() as $name) {
$field = $e[0].".".$name; $field = $e[0].'.'.$name;
$this->parts["select"][$field] = $field." AS ".$e[0]."__".$name; $this->parts['select'][$field] = $field.' AS '.$e[0].'__'.$name;
} }
} else { } else {
$field = $e[0].".".$e[1]; $field = $e[0].'.'.$e[1];
$this->parts["select"][$field] = $field." AS ".$e[0]."__".$e[1]; $this->parts['select'][$field] = $field.' AS '.$e[0].'__'.$e[1];
} }
} }
@ -169,7 +169,7 @@ class Doctrine_RawSql extends Doctrine_Hydrate
} }
} }
$q = 'SELECT '.implode(', ', $this->parts['select']); $q = 'SELECT ' . implode(', ', $this->parts['select']);
$string = $this->applyInheritance(); $string = $this->applyInheritance();
if ( ! empty($string)) { if ( ! empty($string)) {