Commit e0eafb56 authored by zYne's avatar zYne

--no commit message

--no commit message
parent 6cb07b57
...@@ -166,6 +166,10 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable ...@@ -166,6 +166,10 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
* @var Doctrine_Tree $tree tree object associated with this table * @var Doctrine_Tree $tree tree object associated with this table
*/ */
protected $tree; protected $tree;
/**
* @var Doctrine_Relation_Parser $_parser relation parser object
*/
protected $_parser;
/** /**
* the constructor * the constructor
* @throws Doctrine_Connection_Exception if there are no opened connections * @throws Doctrine_Connection_Exception if there are no opened connections
...@@ -179,9 +183,10 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable ...@@ -179,9 +183,10 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
$this->setParent($this->conn); $this->setParent($this->conn);
$this->options['name'] = $name; $this->options['name'] = $name;
$this->_parser = new Doctrine_Relation_Parser($this);
if ( ! class_exists($name) || empty($name)) { if ( ! class_exists($name) || empty($name)) {
throw new Doctrine_Exception("Couldn't find class $name"); throw new Doctrine_Exception("Couldn't find class " . $name);
} }
$record = new $name($this); $record = new $name($this);
...@@ -192,8 +197,9 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable ...@@ -192,8 +197,9 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
// get parent classes // get parent classes
do { do {
if ($class == "Doctrine_Record") if ($class == "Doctrine_Record") {
break; break;
}
$name = $class; $name = $class;
$names[] = $name; $names[] = $name;
...@@ -207,8 +213,9 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable ...@@ -207,8 +213,9 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
$record->setTableDefinition(); $record->setTableDefinition();
// set the table definition for the given tree implementation // set the table definition for the given tree implementation
if($this->isTree()) if ($this->isTree()) {
$this->getTree()->setTableDefinition(); $this->getTree()->setTableDefinition();
}
$this->columnCount = count($this->columns); $this->columnCount = count($this->columns);
...@@ -284,19 +291,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable ...@@ -284,19 +291,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
$this->identifier = $pk; $this->identifier = $pk;
} }
} }
};
/**
if ( ! isset($definition['values'])) {
throw new Doctrine_Table_Exception('No values set for enum column ' . $name);
} }
if ( ! is_array($definition['values'])) {
throw new Doctrine_Table_Exception('Enum column values should be specified as an array.');
}
*/
} }
} else { } else {
throw new Doctrine_Table_Exception("Class '$name' has no table definition."); throw new Doctrine_Table_Exception("Class '$name' has no table definition.");
...@@ -313,9 +308,6 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable ...@@ -313,9 +308,6 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
array_pop($names); array_pop($names);
$this->options['parents'] = $names; $this->options['parents'] = $names;
$this->query = 'SELECT ' . implode(', ', array_keys($this->columns)) . ' FROM ' . $this->getTableName();
$this->repository = new Doctrine_Table_Repository($this); $this->repository = new Doctrine_Table_Repository($this);
} }
/** /**
...@@ -412,6 +404,16 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable ...@@ -412,6 +404,16 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
throw $e; throw $e;
} }
} }
/**
* getRelationParser
* return the relation parser associated with this table
*
* @return Doctrine_Relation_Parser relation parser object
*/
public function getRelationParser()
{
return $this->_parser;
}
/** /**
* __get * __get
* an alias for getOption * an alias for getOption
...@@ -1048,7 +1050,8 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable ...@@ -1048,7 +1050,8 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
$id = array_values($id); $id = array_values($id);
} }
$query = $this->query . ' WHERE ' . implode(' = ? AND ', $this->primaryKeys) . ' = ?'; $query = 'SELECT ' . implode(', ', array_keys($this->columns)) . ' FROM ' . $this->getTableName()
. ' WHERE ' . implode(' = ? AND ', $this->primaryKeys) . ' = ?';
$query = $this->applyInheritance($query); $query = $this->applyInheritance($query);
$params = array_merge($id, array_values($this->options['inheritanceMap'])); $params = array_merge($id, array_values($this->options['inheritanceMap']));
......
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