Commit 419daa81 authored by zYne's avatar zYne

Small refactorings

parent 9b951928
...@@ -204,6 +204,9 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun ...@@ -204,6 +204,9 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
return count($this->tables); return count($this->tables);
} }
/** /**
* addTable
* adds a Doctrine_Table object into connection registry
*
* @param $objTable a Doctrine_Table object to be added into registry * @param $objTable a Doctrine_Table object to be added into registry
* @return boolean * @return boolean
*/ */
...@@ -217,6 +220,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun ...@@ -217,6 +220,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
return true; return true;
} }
/** /**
* create
* creates a record * creates a record
* *
* create creates a record * create creates a record
...@@ -240,7 +244,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun ...@@ -240,7 +244,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
} }
/** /**
* saveAll * saveAll
* saves all the records from all tables * persists all the records from all tables
* *
* @return void * @return void
*/ */
...@@ -274,6 +278,9 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun ...@@ -274,6 +278,9 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
} }
} }
/** /**
* evictTables
* evicts all tables
*
* @return void * @return void
*/ */
public function evictTables() { public function evictTables() {
...@@ -424,16 +431,10 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun ...@@ -424,16 +431,10 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
$foreign = $fk->getForeign(); $foreign = $fk->getForeign();
if($record->getTable()->hasPrimaryKey($fk->getLocal())) { if($record->getTable()->hasPrimaryKey($fk->getLocal())) {
switch($record->getState()): if( ! $record->exists())
case Doctrine_Record::STATE_TDIRTY:
case Doctrine_Record::STATE_TCLEAN:
$saveLater[$k] = $fk; $saveLater[$k] = $fk;
break; else
case Doctrine_Record::STATE_CLEAN:
case Doctrine_Record::STATE_DIRTY:
$v->save(); $v->save();
break;
endswitch;
} else { } else {
// ONE-TO-ONE relationship // ONE-TO-ONE relationship
$obj = $record->get($fk->getTable()->getComponentName()); $obj = $record->get($fk->getTable()->getComponentName());
...@@ -552,10 +553,9 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun ...@@ -552,10 +553,9 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
* @return boolean true on success, false on failure * @return boolean true on success, false on failure
*/ */
final public function delete(Doctrine_Record $record) { final public function delete(Doctrine_Record $record) {
switch($record->getState()): if( ! $record->exists())
case Doctrine_Record::STATE_PROXY: return false;
case Doctrine_Record::STATE_CLEAN:
case Doctrine_Record::STATE_DIRTY:
$this->beginTransaction(); $this->beginTransaction();
$this->deleteComposites($record); $this->deleteComposites($record);
...@@ -563,10 +563,6 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun ...@@ -563,10 +563,6 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
$this->commit(); $this->commit();
return true; return true;
break;
default:
return false;
endswitch;
} }
/** /**
* returns a string representation of this object * returns a string representation of this object
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
*/ */
/** /**
* Doctrine_Transaction * Doctrine_Connection_UnitOfWork
* *
* @package Doctrine ORM * @package Doctrine ORM
* @url www.phpdoctrine.com * @url www.phpdoctrine.com
......
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