Commit 5f1c8d10 authored by zYne's avatar zYne

--no commit message

--no commit message
parent a0958f7d
...@@ -44,9 +44,9 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable { ...@@ -44,9 +44,9 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
*/ */
private $query; private $query;
/** /**
* @var Doctrine_Session $session Doctrine_Session object that created this table * @var Doctrine_Connection $connection Doctrine_Connection object that created this table
*/ */
private $session; private $connection;
/** /**
* @var string $name name of the component, for example component name of the GroupTable is 'Group' * @var string $name name of the component, for example component name of the GroupTable is 'Group'
*/ */
...@@ -111,14 +111,14 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable { ...@@ -111,14 +111,14 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
/** /**
* the constructor * the constructor
* @throws Doctrine_ManagerException if there are no opened sessions * @throws Doctrine_ManagerException if there are no opened connections
* @throws Doctrine_TableException if there is already an instance of this table * @throws Doctrine_TableException if there is already an instance of this table
* @return void * @return void
*/ */
public function __construct($name) { public function __construct($name) {
$this->session = Doctrine_Manager::getInstance()->getCurrentSession(); $this->connection = Doctrine_Manager::getInstance()->getCurrentConnection();
$this->setParent($this->session); $this->setParent($this->connection);
$this->name = $name; $this->name = $name;
...@@ -206,7 +206,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable { ...@@ -206,7 +206,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
endswitch; endswitch;
if(Doctrine_DataDict::isValidClassname($class->getName()) && $this->getAttribute(Doctrine::ATTR_CREATE_TABLES)) { if(Doctrine_DataDict::isValidClassname($class->getName()) && $this->getAttribute(Doctrine::ATTR_CREATE_TABLES)) {
$dict = new Doctrine_DataDict($this->getSession()->getDBH()); $dict = new Doctrine_DataDict($this->getConnection()->getDBH());
$dict->createTable($this->tableName, $this->columns); $dict->createTable($this->tableName, $this->columns);
} }
...@@ -224,7 +224,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable { ...@@ -224,7 +224,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
$this->query = "SELECT ".implode(", ",array_keys($this->columns))." FROM ".$this->getTableName(); $this->query = "SELECT ".implode(", ",array_keys($this->columns))." FROM ".$this->getTableName();
// check if an instance of this table is already initialized // check if an instance of this table is already initialized
if( ! $this->session->addTable($this)) if( ! $this->connection->addTable($this))
throw new Doctrine_Table_Exception(); throw new Doctrine_Table_Exception();
$this->initComponents(); $this->initComponents();
...@@ -501,10 +501,10 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable { ...@@ -501,10 +501,10 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
return $this->name; return $this->name;
} }
/** /**
* @return Doctrine_Session * @return Doctrine_Connection
*/ */
final public function getSession() { final public function getConnection() {
return $this->session; return $this->connection;
} }
/** /**
* @return Doctrine_Cache * @return Doctrine_Cache
...@@ -551,7 +551,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable { ...@@ -551,7 +551,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
$alias = $name; $alias = $name;
$name = $this->bound[$alias][3]; $name = $this->bound[$alias][3];
$table = $this->session->getTable($name); $table = $this->connection->getTable($name);
if($component == $this->name || in_array($component, $this->parents)) { if($component == $this->name || in_array($component, $this->parents)) {
...@@ -597,7 +597,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable { ...@@ -597,7 +597,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
if($e2[0] != $component) if($e2[0] != $component)
throw new Doctrine_Mapping_Exception($e2[0]." doesn't match ".$component); throw new Doctrine_Mapping_Exception($e2[0]." doesn't match ".$component);
$associationTable = $this->session->getTable($e2[0]); $associationTable = $this->connection->getTable($e2[0]);
if(count($fields) > 1) { if(count($fields) > 1) {
// SELF-REFERENCING THROUGH JOIN TABLE // SELF-REFERENCING THROUGH JOIN TABLE
...@@ -683,7 +683,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable { ...@@ -683,7 +683,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
$params = array_merge($id, array_values($this->inheritanceMap)); $params = array_merge($id, array_values($this->inheritanceMap));
$stmt = $this->session->execute($query,$params); $stmt = $this->connection->execute($query,$params);
$this->data = $stmt->fetch(PDO::FETCH_ASSOC); $this->data = $stmt->fetch(PDO::FETCH_ASSOC);
...@@ -715,7 +715,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable { ...@@ -715,7 +715,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
* @return Doctrine_Collection * @return Doctrine_Collection
*/ */
public function findAll() { public function findAll() {
$graph = new Doctrine_Query($this->session); $graph = new Doctrine_Query($this->connection);
$users = $graph->query("FROM ".$this->name); $users = $graph->query("FROM ".$this->name);
return $users; return $users;
} }
...@@ -729,7 +729,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable { ...@@ -729,7 +729,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
* @return Doctrine_Collection * @return Doctrine_Collection
*/ */
public function findBySql($dql, array $params = array()) { public function findBySql($dql, array $params = array()) {
$q = new Doctrine_Query($this->session); $q = new Doctrine_Query($this->connection);
$users = $q->query("FROM ".$this->name." WHERE ".$dql, $params); $users = $q->query("FROM ".$this->name." WHERE ".$dql, $params);
return $users; return $users;
} }
...@@ -791,7 +791,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable { ...@@ -791,7 +791,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
$params = array_merge(array($id), array_values($this->inheritanceMap)); $params = array_merge(array($id), array_values($this->inheritanceMap));
$this->data = $this->session->execute($query,$params)->fetch(PDO::FETCH_ASSOC); $this->data = $this->connection->execute($query,$params)->fetch(PDO::FETCH_ASSOC);
if($this->data === false) if($this->data === false)
throw new Doctrine_Find_Exception(); throw new Doctrine_Find_Exception();
...@@ -811,14 +811,14 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable { ...@@ -811,14 +811,14 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
* @return integer * @return integer
*/ */
public function count() { public function count() {
$a = $this->session->getDBH()->query("SELECT COUNT(1) FROM ".$this->tableName)->fetch(PDO::FETCH_NUM); $a = $this->connection->getDBH()->query("SELECT COUNT(1) FROM ".$this->tableName)->fetch(PDO::FETCH_NUM);
return current($a); return current($a);
} }
/** /**
* @return Doctrine_Query a Doctrine_Query object * @return Doctrine_Query a Doctrine_Query object
*/ */
public function getQueryObject() { public function getQueryObject() {
$graph = new Doctrine_Query($this->getSession()); $graph = new Doctrine_Query($this->getConnection());
$graph->load($this->getComponentName()); $graph->load($this->getComponentName());
return $graph; return $graph;
} }
...@@ -831,12 +831,12 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable { ...@@ -831,12 +831,12 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
*/ */
public function execute($query, array $array = array(), $limit = null, $offset = null) { public function execute($query, array $array = array(), $limit = null, $offset = null) {
$coll = new Doctrine_Collection($this); $coll = new Doctrine_Collection($this);
$query = $this->session->modifyLimitQuery($query,$limit,$offset); $query = $this->connection->modifyLimitQuery($query,$limit,$offset);
if( ! empty($array)) { if( ! empty($array)) {
$stmt = $this->session->getDBH()->prepare($query); $stmt = $this->connection->getDBH()->prepare($query);
$stmt->execute($array); $stmt->execute($array);
} else { } else {
$stmt = $this->session->getDBH()->query($query); $stmt = $this->connection->getDBH()->query($query);
} }
$data = $stmt->fetchAll(PDO::FETCH_ASSOC); $data = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
...@@ -944,7 +944,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable { ...@@ -944,7 +944,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable {
*/ */
final public function getMaxIdentifier() { final public function getMaxIdentifier() {
$sql = "SELECT MAX(".$this->getIdentifier().") FROM ".$this->getTableName(); $sql = "SELECT MAX(".$this->getIdentifier().") FROM ".$this->getTableName();
$stmt = $this->session->getDBH()->query($sql); $stmt = $this->connection->getDBH()->query($sql);
$data = $stmt->fetch(PDO::FETCH_NUM); $data = $stmt->fetch(PDO::FETCH_NUM);
return isset($data[0])?$data[0]:1; return isset($data[0])?$data[0]:1;
} }
......
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