1
0
mirror of synced 2025-01-29 19:41:45 +03:00
This commit is contained in:
zYne 2006-08-21 23:19:15 +00:00
parent f10d1fca7e
commit 034744caeb
11 changed files with 99 additions and 99 deletions

View File

@ -75,7 +75,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
$table = Doctrine_Manager::getInstance() $table = Doctrine_Manager::getInstance()
->getCurrentConnection() ->getCurrentConnection()
->getTable($table); ->getTable($table);
$this->table = $table; $this->table = $table;
$name = $table->getAttribute(Doctrine::ATTR_COLL_KEY); $name = $table->getAttribute(Doctrine::ATTR_COLL_KEY);
@ -122,7 +122,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
*/ */
public function unserialize($serialized) { public function unserialize($serialized) {
$manager = Doctrine_Manager::getInstance(); $manager = Doctrine_Manager::getInstance();
$session = $manager->getCurrentSession(); $connection = $manager->getCurrentConnection();
$array = unserialize($serialized); $array = unserialize($serialized);
@ -130,7 +130,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
$this->$name = $values; $this->$name = $values;
} }
$this->table = $session->getTable($this->table); $this->table = $connection->getTable($this->table);
$this->expanded = array(); $this->expanded = array();
$this->expandable = true; $this->expandable = true;
@ -287,7 +287,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
$query = "SELECT ".$foreign." FROM ".$asf->getTableName()." WHERE ".$local."=".$this->getIncremented(); $query = "SELECT ".$foreign." FROM ".$asf->getTableName()." WHERE ".$local."=".$this->getIncremented();
$table = $fk->getTable(); $table = $fk->getTable();
$graph = new Doctrine_Query($table->getSession()); $graph = new Doctrine_Query($table->getConnection());
$q = "FROM ".$table->getComponentName()." WHERE ".$table->getComponentName().".".$table->getIdentifier()." IN ($query)"; $q = "FROM ".$table->getComponentName()." WHERE ".$table->getComponentName().".".$table->getIdentifier()." IN ($query)";
@ -526,7 +526,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
* @param mixed $name * @param mixed $name
*/ */
public function loadRelated($name = null) { public function loadRelated($name = null) {
$query = new Doctrine_Query($this->table->getSession()); $query = new Doctrine_Query($this->table->getConnection());
if( ! isset($name)) { if( ! isset($name)) {
foreach($this->data as $record): foreach($this->data as $record):
@ -639,7 +639,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
* @return void * @return void
*/ */
public function save() { public function save() {
$this->table->getSession()->saveCollection($this); $this->table->getConnection()->saveCollection($this);
} }
/** /**
* single shot delete * single shot delete
@ -648,7 +648,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
* @return boolean * @return boolean
*/ */
public function delete() { public function delete() {
$ids = $this->table->getSession()->deleteCollection($this); $ids = $this->table->getConnection()->deleteCollection($this);
$this->data = array(); $this->data = array();
} }
/** /**

View File

@ -20,7 +20,7 @@
*/ */
/** /**
* Doctrine_Configurable * Doctrine_Configurable
* the base for Doctrine_Table, Doctrine_Manager and Doctrine_Session * the base for Doctrine_Table, Doctrine_Manager and Doctrine_Connection
* *
* *
* @package Doctrine ORM * @package Doctrine ORM
@ -89,17 +89,17 @@ abstract class Doctrine_Configurable {
break; break;
case Doctrine::ATTR_LOCKMODE: case Doctrine::ATTR_LOCKMODE:
if($this instanceof Doctrine_Session) { if($this instanceof Doctrine_Connection) {
if($this->getState() != Doctrine_Session::STATE_OPEN) if($this->getState() != Doctrine_Connection::STATE_OPEN)
throw new Doctrine_Exception("Couldn't set lockmode. There are transactions open."); throw new Doctrine_Exception("Couldn't set lockmode. There are transactions open.");
} elseif($this instanceof Doctrine_Manager) { } elseif($this instanceof Doctrine_Manager) {
foreach($this as $session) { foreach($this as $connection) {
if($session->getState() != Doctrine_Session::STATE_OPEN) if($connection->getState() != Doctrine_Connection::STATE_OPEN)
throw new Doctrine_Exception("Couldn't set lockmode. There are transactions open."); throw new Doctrine_Exception("Couldn't set lockmode. There are transactions open.");
} }
} else { } else {
throw new Doctrine_Exception("Lockmode attribute can only be set at the global or session level."); throw new Doctrine_Exception("Lockmode attribute can only be set at the global or connection level.");
} }
break; break;
case Doctrine::ATTR_CREATE_TABLES: case Doctrine::ATTR_CREATE_TABLES:

View File

@ -45,19 +45,19 @@ abstract class Doctrine_EventListener implements Doctrine_EventListener_Interfac
public function onDeleteCascade(Doctrine_Record $record) { } public function onDeleteCascade(Doctrine_Record $record) { }
public function onPreDeleteCascade(Doctrine_Record $record) { } public function onPreDeleteCascade(Doctrine_Record $record) { }
public function onClose(Doctrine_Session $session) { } public function onClose(Doctrine_Connection $connection) { }
public function onPreClose(Doctrine_Session $session) { } public function onPreClose(Doctrine_Connection $connection) { }
public function onOpen(Doctrine_Session $session) { } public function onOpen(Doctrine_Connection $connection) { }
public function onTransactionCommit(Doctrine_Session $session) { } public function onTransactionCommit(Doctrine_Connection $connection) { }
public function onPreTransactionCommit(Doctrine_Session $session) { } public function onPreTransactionCommit(Doctrine_Connection $connection) { }
public function onTransactionRollback(Doctrine_Session $session) { } public function onTransactionRollback(Doctrine_Connection $connection) { }
public function onPreTransactionRollback(Doctrine_Session $session) { } public function onPreTransactionRollback(Doctrine_Connection $connection) { }
public function onTransactionBegin(Doctrine_Session $session) { } public function onTransactionBegin(Doctrine_Connection $connection) { }
public function onPreTransactionBegin(Doctrine_Session $session) { } public function onPreTransactionBegin(Doctrine_Connection $connection) { }
public function onCollectionDelete(Doctrine_Collection $collection) { } public function onCollectionDelete(Doctrine_Collection $collection) { }
public function onPreCollectionDelete(Doctrine_Collection $collection) { } public function onPreCollectionDelete(Doctrine_Collection $collection) { }

View File

@ -50,9 +50,9 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
*/ */
protected $data = array(); protected $data = array();
/** /**
* @var Doctrine_Session $session Doctrine_Session object * @var Doctrine_Connection $connection Doctrine_Connection object
*/ */
protected $session; protected $connection;
/** /**
* @var Doctrine_View $view Doctrine_View object * @var Doctrine_View $view Doctrine_View object
*/ */
@ -90,10 +90,10 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
* @param Doctrine_Connection|null $connection * @param Doctrine_Connection|null $connection
*/ */
public function __construct($connection = null) { public function __construct($connection = null) {
if( ! ($connection instanceof Doctrine_Session)) if( ! ($connection instanceof Doctrine_Connection))
$connection = Doctrine_Manager::getInstance()->getCurrentConnection(); $connection = Doctrine_Manager::getInstance()->getCurrentConnection();
$this->session = $connection; $this->connection = $connection;
} }
/** /**
* getQuery * getQuery
@ -151,10 +151,10 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
$this->tableAliases = array(); $this->tableAliases = array();
} }
/** /**
* @return Doctrine_Session * @return Doctrine_Connection
*/ */
public function getSession() { public function getConnection() {
return $this->session; return $this->connection;
} }
/** /**
* setView * setView
@ -255,7 +255,7 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
$keys = array_keys($this->tables); $keys = array_keys($this->tables);
$name = $this->tables[$keys[0]]->getComponentName(); $name = $this->tables[$keys[0]]->getComponentName();
$stmt = $this->session->execute($query,$params); $stmt = $this->connection->execute($query,$params);
while($data = $stmt->fetch(PDO::FETCH_ASSOC)): while($data = $stmt->fetch(PDO::FETCH_ASSOC)):
foreach($data as $key => $value): foreach($data as $key => $value):
@ -279,7 +279,7 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
if($this->isLimitSubqueryUsed()) if($this->isLimitSubqueryUsed())
$params = array_merge($params, $params); $params = array_merge($params, $params);
$stmt = $this->session->execute($query,$params); $stmt = $this->connection->execute($query,$params);
$previd = array(); $previd = array();

View File

@ -68,40 +68,40 @@ class Doctrine_Lib {
} }
/** /**
* getStateAsString * getStateAsString
* returns a given session state as string * returns a given connection state as string
* @param integer $state session state * @param integer $state connection state
*/ */
public static function getSessionStateAsString($state) { public static function getConnectionStateAsString($state) {
switch($state): switch($state):
case Doctrine_Session::STATE_OPEN: case Doctrine_Connection::STATE_OPEN:
return "open"; return "open";
break; break;
case Doctrine_Session::STATE_CLOSED: case Doctrine_Connection::STATE_CLOSED:
return "closed"; return "closed";
break; break;
case Doctrine_Session::STATE_BUSY: case Doctrine_Connection::STATE_BUSY:
return "busy"; return "busy";
break; break;
case Doctrine_Session::STATE_ACTIVE: case Doctrine_Connection::STATE_ACTIVE:
return "active"; return "active";
break; break;
endswitch; endswitch;
} }
/** /**
* returns a string representation of Doctrine_Session object * returns a string representation of Doctrine_Connection object
* @param Doctrine_Session $session * @param Doctrine_Connection $connection
* @return string * @return string
*/ */
public static function getSessionAsString(Doctrine_Session $session) { public static function getConnectionAsString(Doctrine_Connection $connection) {
$r[] = "<pre>"; $r[] = "<pre>";
$r[] = "Doctrine_Session object"; $r[] = "Doctrine_Connection object";
$r[] = "State : ".Doctrine_Lib::getSessionStateAsString($session->getState()); $r[] = "State : ".Doctrine_Lib::getConnectionStateAsString($connection->getState());
$r[] = "Open Transactions : ".$session->getTransactionLevel(); $r[] = "Open Transactions : ".$connection->getTransactionLevel();
$r[] = "Open Factories : ".$session->count(); $r[] = "Open Factories : ".$connection->count();
$sum = 0; $sum = 0;
$rsum = 0; $rsum = 0;
$csum = 0; $csum = 0;
foreach($session->getTables() as $objTable) { foreach($connection->getTables() as $objTable) {
if($objTable->getCache() instanceof Doctrine_Cache_File) { if($objTable->getCache() instanceof Doctrine_Cache_File) {
$sum += array_sum($objTable->getCache()->getStats()); $sum += array_sum($objTable->getCache()->getStats());
$rsum += $objTable->getRepository()->count(); $rsum += $objTable->getRepository()->count();
@ -113,11 +113,11 @@ class Doctrine_Lib {
$r[] = "Repositories : ".$rsum." objects "; $r[] = "Repositories : ".$rsum." objects ";
$queries = false; $queries = false;
if($session->getDBH() instanceof Doctrine_DB) { if($connection->getDBH() instanceof Doctrine_DB) {
$handler = "Doctrine Database Handler"; $handler = "Doctrine Database Handler";
$queries = count($session->getDBH()->getQueries()); $queries = count($connection->getDBH()->getQueries());
$sum = array_sum($session->getDBH()->getExecTimes()); $sum = array_sum($connection->getDBH()->getExecTimes());
} elseif($session->getDBH() instanceof PDO) { } elseif($connection->getDBH() instanceof PDO) {
$handler = "PHP Native PDO Driver"; $handler = "PHP Native PDO Driver";
} else } else
$handler = "Unknown Database Handler"; $handler = "Unknown Database Handler";

View File

@ -26,7 +26,7 @@ require_once("EventListener.php");
* @license LGPL * @license LGPL
* *
* Doctrine_Manager is the base component of all doctrine based projects. * Doctrine_Manager is the base component of all doctrine based projects.
* It opens and keeps track of all sessions (database connections). * It opens and keeps track of all connections (database connections).
*/ */
class Doctrine_Manager extends Doctrine_Configurable implements Countable, IteratorAggregate { class Doctrine_Manager extends Doctrine_Configurable implements Countable, IteratorAggregate {
/** /**
@ -38,7 +38,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
*/ */
private $index = 0; private $index = 0;
/** /**
* @var integer $currIndex the current session index * @var integer $currIndex the current connection index
*/ */
private $currIndex = 0; private $currIndex = 0;
/** /**
@ -144,11 +144,11 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
} }
/** /**
* openConnection * openConnection
* opens a new connection and saves it to Doctrine_Manager->sessions * opens a new connection and saves it to Doctrine_Manager->connections
* *
* @param PDO $pdo PDO database driver * @param PDO $pdo PDO database driver
* @param string $name name of the connection, if empty numeric key is used * @param string $name name of the connection, if empty numeric key is used
* @return Doctrine_Session * @return Doctrine_Connection
*/ */
public function openConnection(PDO $pdo, $name = null) { public function openConnection(PDO $pdo, $name = null) {
// initialize the default attributes // initialize the default attributes
@ -157,7 +157,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
if($name !== null) { if($name !== null) {
$name = (string) $name; $name = (string) $name;
if(isset($this->connections[$name])) if(isset($this->connections[$name]))
throw new InvalidKeyException(); throw new Doctrine_Exception("Connection with $name already exists!");
} else { } else {
$name = $this->index; $name = $this->index;
@ -165,25 +165,25 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
} }
switch($pdo->getAttribute(PDO::ATTR_DRIVER_NAME)): switch($pdo->getAttribute(PDO::ATTR_DRIVER_NAME)):
case "mysql": case "mysql":
$this->connections[$name] = new Doctrine_Session_Mysql($this,$pdo); $this->connections[$name] = new Doctrine_Connection_Mysql($this,$pdo);
break; break;
case "sqlite": case "sqlite":
$this->connections[$name] = new Doctrine_Session_Sqlite($this,$pdo); $this->connections[$name] = new Doctrine_Connection_Sqlite($this,$pdo);
break; break;
case "pgsql": case "pgsql":
$this->connections[$name] = new Doctrine_Session_Pgsql($this,$pdo); $this->connections[$name] = new Doctrine_Connection_Pgsql($this,$pdo);
break; break;
case "oci": case "oci":
$this->connections[$name] = new Doctrine_Session_Oracle($this,$pdo); $this->connections[$name] = new Doctrine_Connection_Oracle($this,$pdo);
break; break;
case "mssql": case "mssql":
$this->connections[$name] = new Doctrine_Session_Mssql($this,$pdo); $this->connections[$name] = new Doctrine_Connection_Mssql($this,$pdo);
break; break;
case "firebird": case "firebird":
$this->connections[$name] = new Doctrine_Session_Firebird($this,$pdo); $this->connections[$name] = new Doctrine_Connection_Firebird($this,$pdo);
break; break;
case "informix": case "informix":
$this->connections[$name] = new Doctrine_Session_Informix($this,$pdo); $this->connections[$name] = new Doctrine_Connection_Informix($this,$pdo);
break; break;
endswitch; endswitch;
@ -195,9 +195,9 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
return $this->openConnection($pdo, $name); return $this->openConnection($pdo, $name);
} }
/** /**
* getSession * getConnection
* @param integer $index * @param integer $index
* @return object Doctrine_Session * @return object Doctrine_Connection
* @throws InvalidKeyException * @throws InvalidKeyException
*/ */
public function getConnection($index) { public function getConnection($index) {
@ -210,16 +210,16 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
public function getSession($index) { return $this->getConnection($index); } public function getSession($index) { return $this->getConnection($index); }
/** /**
* closes the session * closes the connection
* *
* @param Doctrine_Session $session * @param Doctrine_Connection $connection
* @return void * @return void
*/ */
public function closeConnection(Doctrine_Session $session) { public function closeConnection(Doctrine_Connection $connection) {
$session->close(); $connection->close();
unset($session); unset($connection);
} }
public function closeSession(Doctrine_Session $session) { $this->closeConnection($session); } public function closeSession(Doctrine_Connection $connection) { $this->closeConnection($connection); }
/** /**
* getConnections * getConnections
* returns all opened connections * returns all opened connections
@ -252,7 +252,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
} }
/** /**
* count * count
* returns the number of opened sessions * returns the number of opened connections
* *
* @return integer * @return integer
*/ */
@ -261,7 +261,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
} }
/** /**
* getIterator * getIterator
* returns an ArrayIterator that iterates through all sessions * returns an ArrayIterator that iterates through all connections
* *
* @return ArrayIterator * @return ArrayIterator
*/ */
@ -272,13 +272,13 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
* getCurrentConnection * getCurrentConnection
* returns the current connection * returns the current connection
* *
* @throws Doctrine_Session_Exception if there are no open sessions * @throws Doctrine_Connection_Exception if there are no open connections
* @return Doctrine_Session * @return Doctrine_Connection
*/ */
public function getCurrentConnection() { public function getCurrentConnection() {
$i = $this->currIndex; $i = $this->currIndex;
if( ! isset($this->connections[$i])) if( ! isset($this->connections[$i]))
throw new Doctrine_Session_Exception(); throw new Doctrine_Connection_Exception();
return $this->connections[$i]; return $this->connections[$i];
} }
@ -292,7 +292,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
public function __toString() { public function __toString() {
$r[] = "<pre>"; $r[] = "<pre>";
$r[] = "Doctrine_Manager"; $r[] = "Doctrine_Manager";
$r[] = "Sessions : ".count($this->connections); $r[] = "Connections : ".count($this->connections);
$r[] = "</pre>"; $r[] = "</pre>";
return implode("\n",$r); return implode("\n",$r);
} }

View File

@ -31,9 +31,9 @@ class Doctrine_Module implements IteratorAggregate, Countable {
* @return void * @return void
*/ */
public function flush() { public function flush() {
$session = Doctrine_Manager::getInstance()->getCurrentSession(); $connection = Doctrine_Manager::getInstance()->getCurrentConnection();
$tree = $session->buildFlushTree($this->components); $tree = $connection->buildFlushTree($this->components);
} }
/** /**
* getIterator * getIterator

View File

@ -68,7 +68,7 @@ class Doctrine_Query extends Doctrine_Hydrate {
if( ! empty($having)) if( ! empty($having))
$q .= " HAVING ".implode(' AND ',$having); $q .= " HAVING ".implode(' AND ',$having);
$a = $this->getSession()->execute($q, $params)->fetch(PDO::FETCH_NUM); $a = $this->getConnection()->execute($q, $params)->fetch(PDO::FETCH_NUM);
return $a[0]; return $a[0];
} }
/** /**
@ -320,7 +320,7 @@ class Doctrine_Query extends Doctrine_Hydrate {
$modifyLimit = false; $modifyLimit = false;
if( ! empty($this->parts["limit"]) || ! empty($this->parts["offset"])) { if( ! empty($this->parts["limit"]) || ! empty($this->parts["offset"])) {
if($needsSubQuery) { if($needsSubQuery) {
$subquery = $this->session->modifyLimitQuery($subquery,$this->parts["limit"],$this->parts["offset"]); $subquery = $this->connection->modifyLimitQuery($subquery,$this->parts["limit"],$this->parts["offset"]);
$field = $table->getTableName().'.'.$table->getIdentifier(); $field = $table->getTableName().'.'.$table->getIdentifier();
array_unshift($this->parts['where'], $field.' IN ('.$subquery.')'); array_unshift($this->parts['where'], $field.' IN ('.$subquery.')');
@ -333,7 +333,7 @@ class Doctrine_Query extends Doctrine_Hydrate {
$q .= ( ! empty($this->parts['having']))?" HAVING ".implode(" ",$this->parts["having"]):''; $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['orderby']))?" ORDER BY ".implode(" ",$this->parts["orderby"]):'';
if($modifyLimit) if($modifyLimit)
$q = $this->session->modifyLimitQuery($q,$this->parts["limit"],$this->parts["offset"]); $q = $this->connection->modifyLimitQuery($q,$this->parts["limit"],$this->parts["offset"]);
// return to the previous state // return to the previous state
if( ! empty($string)) if( ! empty($string))
@ -358,7 +358,7 @@ class Doctrine_Query extends Doctrine_Hydrate {
if($this->aggregate) { if($this->aggregate) {
$keys = array_keys($this->tables); $keys = array_keys($this->tables);
$query = $this->getQuery(); $query = $this->getQuery();
$stmt = $this->tables[$keys[0]]->getSession()->select($query,$this->parts["limit"],$this->parts["offset"]); $stmt = $this->tables[$keys[0]]->getConnection()->select($query,$this->parts["limit"],$this->parts["offset"]);
$data = $stmt->fetch(PDO::FETCH_ASSOC); $data = $stmt->fetch(PDO::FETCH_ASSOC);
if(count($data) == 1) { if(count($data) == 1) {
return current($data); return current($data);
@ -573,7 +573,7 @@ class Doctrine_Query extends Doctrine_Hydrate {
if($key == 0) { if($key == 0) {
$currPath = substr($currPath,1); $currPath = substr($currPath,1);
$table = $this->session->getTable($name); $table = $this->connection->getTable($name);
$tname = $table->getTableName(); $tname = $table->getTableName();

View File

@ -203,7 +203,7 @@ class Doctrine_RawSql extends Doctrine_Hydrate {
else else
$alias = $tableAlias; $alias = $tableAlias;
$table = $this->session->getTable($component); $table = $this->connection->getTable($component);
$this->tables[$alias] = $table; $this->tables[$alias] = $table;
$this->fetchModes[$alias] = Doctrine::FETCH_IMMEDIATE; $this->fetchModes[$alias] = Doctrine::FETCH_IMMEDIATE;
$this->tableAliases[$currPath] = $alias; $this->tableAliases[$currPath] = $alias;

View File

@ -141,23 +141,23 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
/** /**
* constructor * constructor
* @param Doctrine_Table $table a Doctrine_Table object * @param Doctrine_Table $table a Doctrine_Table object
* @throws Doctrine_Session_Exception if object is created using the new operator and there are no * @throws Doctrine_Connection_Exception if object is created using the new operator and there are no
* open sessions * open connections
*/ */
public function __construct($table = null) { public function __construct($table = null) {
if(isset($table) && $table instanceof Doctrine_Table) { if(isset($table) && $table instanceof Doctrine_Table) {
$this->table = $table; $this->table = $table;
$exists = ( ! $this->table->isNewEntry()); $exists = ( ! $this->table->isNewEntry());
} else { } else {
$this->table = Doctrine_Manager::getInstance()->getCurrentSession()->getTable(get_class($this)); $this->table = Doctrine_Manager::getInstance()->getCurrentConnection()->getTable(get_class($this));
$exists = false; $exists = false;
} }
// Check if the current session has the records table in its registry // Check if the current connection has the records table in its registry
// If not this is record is only used for creating table definition and setting up // If not this is record is only used for creating table definition and setting up
// relations. // relations.
if($this->table->getSession()->hasTable($this->table->getComponentName())) { if($this->table->getConnection()->hasTable($this->table->getComponentName())) {
$this->oid = self::$index; $this->oid = self::$index;
@ -373,12 +373,12 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
*/ */
public function unserialize($serialized) { public function unserialize($serialized) {
$manager = Doctrine_Manager::getInstance(); $manager = Doctrine_Manager::getInstance();
$session = $manager->getCurrentSession(); $connection = $manager->getCurrentConnection();
$this->oid = self::$index; $this->oid = self::$index;
self::$index++; self::$index++;
$this->table = $session->getTable(get_class($this)); $this->table = $connection->getTable(get_class($this));
$array = unserialize($serialized); $array = unserialize($serialized);
@ -462,7 +462,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$id = array_values($id); $id = array_values($id);
$query = $this->table->getQuery()." WHERE ".implode(" = ? AND ",$this->table->getPrimaryKeys())." = ?"; $query = $this->table->getQuery()." WHERE ".implode(" = ? AND ",$this->table->getPrimaryKeys())." = ?";
$this->data = $this->table->getSession()->execute($query,$id)->fetch(PDO::FETCH_ASSOC); $this->data = $this->table->getConnection()->execute($query,$id)->fetch(PDO::FETCH_ASSOC);
$this->modified = array(); $this->modified = array();
$this->cleanData(); $this->cleanData();
@ -741,11 +741,11 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @return void * @return void
*/ */
final public function save() { final public function save() {
$this->table->getSession()->beginTransaction(); $this->table->getConnection()->beginTransaction();
$saveLater = $this->table->getSession()->saveRelated($this); $saveLater = $this->table->getConnection()->saveRelated($this);
$this->table->getSession()->save($this); $this->table->getConnection()->save($this);
foreach($saveLater as $fk) { foreach($saveLater as $fk) {
$table = $fk->getTable(); $table = $fk->getTable();
@ -761,7 +761,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$this->saveAssociations(); $this->saveAssociations();
$this->table->getSession()->commit(); $this->table->getConnection()->commit();
} }
/** /**
* returns an array of modified fields and associated values * returns an array of modified fields and associated values
@ -866,7 +866,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
foreach($r as $record) { foreach($r as $record) {
$query = "DELETE FROM ".$asf->getTableName()." WHERE ".$fk->getForeign()." = ?" $query = "DELETE FROM ".$asf->getTableName()." WHERE ".$fk->getForeign()." = ?"
." AND ".$fk->getLocal()." = ?"; ." AND ".$fk->getLocal()." = ?";
$this->table->getSession()->execute($query, array($record->getIncremented(),$this->getIncremented())); $this->table->getConnection()->execute($query, array($record->getIncremented(),$this->getIncremented()));
} }
$r = Doctrine_Relation::getInsertOperations($this->originals[$alias],$new); $r = Doctrine_Relation::getInsertOperations($this->originals[$alias],$new);
@ -928,7 +928,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @return boolean true on success, false on failure * @return boolean true on success, false on failure
*/ */
public function delete() { public function delete() {
return $this->table->getSession()->delete($this); return $this->table->getConnection()->delete($this);
} }
/** /**
* returns a copy of this object * returns a copy of this object

View File

@ -41,7 +41,7 @@ class Doctrine_View {
$this->name = $viewName; $this->name = $viewName;
$this->query = $query; $this->query = $query;
$this->query->setView($this); $this->query->setView($this);
$this->dbh = $query->getSession()->getDBH(); $this->dbh = $query->getConnection()->getDBH();
} }
/** /**
* simple get method for getting * simple get method for getting