1
0
mirror of synced 2024-12-14 07:06:04 +03:00
This commit is contained in:
zYne 2007-06-26 10:23:23 +00:00
parent 87474aa019
commit 4ed4477177
2 changed files with 34 additions and 24 deletions

View File

@ -131,6 +131,39 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
}
return array_values($tree);
}
/**
* saves the given record
*
* @param Doctrine_Record $record
* @return void
*/
public function saveGraph(Doctrine_Record $record)
{
$conn = $this->getConnection();
$conn->beginTransaction();
$saveLater = $this->saveRelated($record);
if ($record->isValid()) {
$this->save($record);
} else {
$conn->transaction->addInvalid($record);
}
foreach ($saveLater as $fk) {
$alias = $fk->getAlias();
if ($record->hasReference($alias)) {
$obj = $record->$alias;
$obj->save($conn);
}
}
// save the MANY-TO-MANY associations
$this->saveAssociations($record);
$conn->commit();
}
/**
* saves the given record
*

View File

@ -948,30 +948,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
if ($conn === null) {
$conn = $this->_table->getConnection();
}
$conn->beginTransaction();
$saveLater = $conn->unitOfWork->saveRelated($this);
if ($this->isValid()) {
$conn->unitOfWork->save($this);
} else {
$conn->transaction->addInvalid($this);
}
foreach ($saveLater as $fk) {
$alias = $fk->getAlias();
if (isset($this->_references[$alias])) {
$obj = $this->_references[$alias];
$obj->save($conn);
}
}
// save the MANY-TO-MANY associations
$conn->unitOfWork->saveAssociations($this);
//$this->saveAssociations();
$conn->commit();
$conn->unitOfWork->saveGraph($this);
}
/**
* Tries to save the object and all its related components.