1
0
mirror of synced 2025-01-20 07:21:40 +03:00
This commit is contained in:
zYne 2007-05-21 20:06:18 +00:00
parent 6cb07b57e6
commit e0eafb56d7

View File

@ -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
$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
// 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,9 +213,10 @@ 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);
if (isset($this->columns)) { if (isset($this->columns)) {
@ -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
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,7 +404,17 @@ 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
$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']));