From 86bf9a820194e9612bed24befc78141aa93ca5e0 Mon Sep 17 00:00:00 2001 From: zYne Date: Thu, 28 Sep 2006 20:58:56 +0000 Subject: [PATCH] deleted old relation classes --- lib/Doctrine/Association.php | 99 ------------------------------------ lib/Doctrine/Compiler.php | 2 +- lib/Doctrine/ForeignKey.php | 64 ----------------------- lib/Doctrine/LocalKey.php | 53 ------------------- 4 files changed, 1 insertion(+), 217 deletions(-) delete mode 100644 lib/Doctrine/Association.php delete mode 100644 lib/Doctrine/ForeignKey.php delete mode 100644 lib/Doctrine/LocalKey.php diff --git a/lib/Doctrine/Association.php b/lib/Doctrine/Association.php deleted file mode 100644 index b3daa21dd..000000000 --- a/lib/Doctrine/Association.php +++ /dev/null @@ -1,99 +0,0 @@ -. - */ -/** - * Doctrine_Relation_Association this class takes care of association mapping - * (= many-to-many relationships, where the relationship is handled with an additional relational table - * which holds 2 foreign keys) - * - * - * @package Doctrine ORM - * @url www.phpdoctrine.com - * @license LGPL - */ -class Doctrine_Relation_Association extends Doctrine_Relation { - /** - * @var Doctrine_Table $associationTable - */ - protected $associationTable; - /** - * the constructor - * @param Doctrine_Table $table foreign factory object - * @param Doctrine_Table $associationTable factory which handles the association - * @param string $local local field name - * @param string $foreign foreign field name - * @param integer $type type of relation - * @see Doctrine_Table constants - */ - public function __construct(Doctrine_Table $table, Doctrine_Table $associationTable, $local, $foreign, $type, $alias) { - parent::__construct($table, $local, $foreign, $type, $alias); - $this->associationTable = $associationTable; - } - /** - * @return Doctrine_Table - */ - public function getAssociationFactory() { - return $this->associationTable; - } - /** - * getRelationDql - * - * @param integer $count - * @return string - */ - public function getRelationDql($count, $context = 'record') { - switch($context): - case "record": - $sub = "SELECT ".$this->foreign. - " FROM ".$this->associationTable->getTableName(). - " WHERE ".$this->local. - " IN (".substr(str_repeat("?, ", $count),0,-2).")"; - - $dql = "FROM ".$this->table->getComponentName(); - $dql .= ".".$this->associationTable->getComponentName(); - $dql .= " WHERE ".$this->table->getComponentName().".".$this->table->getIdentifier()." IN ($sub)"; - break; - case "collection": - $sub = substr(str_repeat("?, ", $count),0,-2); - $dql = "FROM ".$this->associationTable->getComponentName().".".$this->table->getComponentName(); - $dql .= " WHERE ".$this->associationTable->getComponentName().".".$this->local." IN ($sub)"; - endswitch; - - return $dql; - } - /** - * fetchRelatedFor - * - * fetches a component related to given record - * - * @param Doctrine_Record $record - * @return Doctrine_Record|Doctrine_Collection - */ - public function fetchRelatedFor(Doctrine_Record $record) { - $id = $record->getIncremented(); - if(empty($id)) - $coll = new Doctrine_Collection($this->table); - else - $coll = Doctrine_Query::create()->parseQuery($this->getRelationDql(1))->execute(array($id)); - - return $coll; - } -} - diff --git a/lib/Doctrine/Compiler.php b/lib/Doctrine/Compiler.php index 16ccfc988..16ad716bb 100644 --- a/lib/Doctrine/Compiler.php +++ b/lib/Doctrine/Compiler.php @@ -85,7 +85,7 @@ class Doctrine_Compiler { * including the compiled file instead of multiple files (in worst * cases dozens of files) can improve performance by an order of magnitude * - * @throws Doctrine_Exception + * @throws Doctrine_Compiler_Exception if something went wrong during the compile operation * @return void */ public static function compile($target = null) { diff --git a/lib/Doctrine/ForeignKey.php b/lib/Doctrine/ForeignKey.php deleted file mode 100644 index 1de724a61..000000000 --- a/lib/Doctrine/ForeignKey.php +++ /dev/null @@ -1,64 +0,0 @@ -. - */ -Doctrine::autoload('Doctrine_Relation'); -/** - * Doctrine_Relation_ForeignKey - * This class represents a foreign key relation - * - * @author Konsta Vesterinen - * @license LGPL - * @package Doctrine - */ -class Doctrine_Relation_ForeignKey extends Doctrine_Relation { - /** - * fetchRelatedFor - * - * fetches a component related to given record - * - * @param Doctrine_Record $record - * @return Doctrine_Record|Doctrine_Collection - */ - public function fetchRelatedFor(Doctrine_Record $record) { - $id = $record->get($this->local); - - if($this->isOneToOne()) { - if(empty($id)) { - $related = $this->table->create(); - } else { - $dql = "FROM ".$this->table->getComponentName()." WHERE ".$this->table->getComponentName().".".$this->foreign." = ?"; - $coll = $this->table->getConnection()->query($dql, array($id)); - $related = $coll[0]; - } - - $related->set($this->foreign, $record, false); - - } else { - if(empty($id)) { - $related = new Doctrine_Collection($this->table); - } else { - $query = $this->getRelationDql(1); - $related = $this->table->getConnection()->query($query, array($id)); - } - $related->setReference($record, $this); - } - return $related; - } -} diff --git a/lib/Doctrine/LocalKey.php b/lib/Doctrine/LocalKey.php deleted file mode 100644 index f3403709e..000000000 --- a/lib/Doctrine/LocalKey.php +++ /dev/null @@ -1,53 +0,0 @@ -. - */ -Doctrine::autoload('Doctrine_Relation'); -/** - * Doctrine_Relation_LocalKey - * This class represents a local key relation - * - * @author Konsta Vesterinen - * @license LGPL - * @package Doctrine - */ -class Doctrine_Relation_LocalKey extends Doctrine_Relation { - /** - * fetchRelatedFor - * - * fetches a component related to given record - * - * @param Doctrine_Record $record - * @return Doctrine_Record|Doctrine_Collection - */ - public function fetchRelatedFor(Doctrine_Record $record) { - $id = $record->get($this->local); - - if(empty($id)) - $related = $this->table->create(); - else { - if( ! ($related = $this->table->find($id))) - $related = $this->table->create(); - } - - $record->set($this->local, $related, false); - - return $related; - } -}