1
0
mirror of synced 2024-12-13 14:56:01 +03:00

Doctrine now works seamlessly in multi-connection environment where connections are bound to classes

This commit is contained in:
zYne 2006-12-05 21:46:38 +00:00
parent 9aeeffe24e
commit 2d29792301
4 changed files with 27 additions and 10 deletions

View File

@ -243,7 +243,19 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
return $this->getConnection($this->bound[$componentName]);
return $this->getCurrentConnection();
}
}
/**
* getTable
* this is the same as Doctrine_Connection::getTable() except
* that it works seamlessly in multi-server/connection environment
*
* @see Doctrine_Connection::getTable()
* @param string $componentName
* @return Doctrine_Table
*/
public function getTable($componentName) {
return $this->getConnectionForComponent($componentName)->getTable($componentName);
}
/**
* closes the connection
*

View File

@ -1059,6 +1059,9 @@ class Doctrine_Query extends Doctrine_Hydrate implements Countable {
if($key == 0) {
$currPath = substr($currPath,1);
$this->conn = Doctrine_Manager::getInstance()
->getConnectionForComponent($name);
$table = $this->conn->getTable($name);

View File

@ -161,20 +161,20 @@ class Doctrine_RawSql extends Doctrine_Hydrate {
}
}
$q = "SELECT ".implode(', ', $this->parts['select']);
$q = 'SELECT '.implode(', ', $this->parts['select']);
$string = $this->applyInheritance();
if( ! empty($string))
$this->parts["where"][] = $string;
$this->parts['where'][] = $string;
$copy = $this->parts;
unset($copy['select']);
$q .= ( ! empty($this->parts['from']))?" FROM ".implode(" ",$this->parts["from"]):'';
$q .= ( ! empty($this->parts['where']))?" WHERE ".implode(" AND ",$this->parts["where"]):'';
$q .= ( ! empty($this->parts['groupby']))?" GROUP BY ".implode(", ",$this->parts["groupby"]):'';
$q .= ( ! empty($this->parts['having']))?" HAVING ".implode(" ",$this->parts["having"]):'';
$q .= ( ! empty($this->parts['orderby']))?" ORDER BY ".implode(" ",$this->parts["orderby"]):'';
$q .= ( ! empty($this->parts['from']))? ' FROM ' . implode(' ', $this->parts['from']) : '';
$q .= ( ! empty($this->parts['where']))? ' WHERE ' . implode(' AND ', $this->parts['where']) : '';
$q .= ( ! empty($this->parts['groupby']))? ' GROUP BY ' . implode(', ', $this->parts['groupby']) : '';
$q .= ( ! empty($this->parts['having']))? ' HAVING ' . implode(' ', $this->parts['having']) : '';
$q .= ( ! empty($this->parts['orderby']))? ' ORDER BY ' . implode(' ', $this->parts['orderby']) : '';
if( ! empty($string))
array_pop($this->parts['where']);
@ -212,7 +212,7 @@ class Doctrine_RawSql extends Doctrine_Hydrate {
else
$alias = $tableAlias;
if ($table) {
if($table) {
$tableName = $table->getAliasName($component);

View File

@ -136,7 +136,9 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$this->_table = $table;
$exists = ( ! $isNewEntry);
} else {
$this->_table = Doctrine_Manager::getInstance()->getCurrentConnection()->getTable(get_class($this));
$class = get_class($this);
// get the table of this class
$this->_table = Doctrine_Manager::getInstance()->getConnectionForComponent($class)->getTable(get_class($this));
$exists = false;
}