This commit is contained in:
parent
87474aa019
commit
4ed4477177
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user