Commit 4ed44771 authored by zYne's avatar zYne

--no commit message

--no commit message
parent 87474aa0
......@@ -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
*
......
......@@ -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.
......
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