Commit 0686aef2 authored by zYne's avatar zYne

--no commit message

--no commit message
parent 714a4223
......@@ -205,6 +205,13 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
// create database table
if (method_exists($record, 'setTableDefinition')) {
$record->setTableDefinition();
// get the declaring class of setTableDefinition method
$method = new ReflectionMethod($this->options['name'], 'setTableDefinition');
$class = $method->getDeclaringClass();
} else {
$class = new ReflectionClass($class);
}
$this->options['declaringClass'] = $class;
// set the table definition for the given tree implementation
if ($this->isTree()) {
......@@ -213,16 +220,10 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
$this->columnCount = count($this->columns);
if (isset($this->columns)) {
// get the declaring class of setTableDefinition method
$method = new ReflectionMethod($this->options['name'], 'setTableDefinition');
$class = $method->getDeclaringClass();
$this->options['declaringClass'] = $class;
if ( ! isset($this->options['tableName'])) {
$this->options['tableName'] = Doctrine::tableize($class->getName());
}
switch (count($this->primaryKeys)) {
case 0:
$this->columns = array_merge(array('id' =>
......@@ -283,10 +284,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
}
}
}
}
} else {
throw new Doctrine_Table_Exception("Class '$name' has no table definition.");
}
$record->setUp();
......@@ -895,7 +893,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
public function findAll()
{
$graph = new Doctrine_Query($this->conn);
$users = $graph->query("FROM ".$this->options['name']);
$users = $graph->query('FROM ' . $this->options['name']);
return $users;
}
/**
......@@ -1047,12 +1045,12 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
if ($id !== null) {
$query = 'SELECT ' . implode(', ',$this->primaryKeys)
. ' FROM ' . $this->getTableName()
. ' WHERE ' . implode(' = ? && ',$this->primaryKeys).' = ?';
. ' WHERE ' . implode(' = ? && ',$this->primaryKeys) . ' = ?';
$query = $this->applyInheritance($query);
$params = array_merge(array($id), array_values($this->options['inheritanceMap']));
$this->data = $this->conn->execute($query,$params)->fetch(PDO::FETCH_ASSOC);
$this->data = $this->conn->execute($query, $params)->fetch(PDO::FETCH_ASSOC);
if ($this->data === false)
return false;
......
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