1
0
mirror of synced 2024-12-13 22:56:04 +03:00
This commit is contained in:
zYne 2007-05-16 21:47:23 +00:00
parent 827755afd3
commit 2291272ebf
4 changed files with 22 additions and 66 deletions

View File

@ -492,7 +492,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
// prepare and execute the statement
$this->execute($query, array_values($values));
print $query . '(' . implode(', ', $values) . ")<br>";
return true;
}
/**

View File

@ -162,22 +162,6 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
}
}
} elseif ($fk instanceof Doctrine_Relation_Association) {
$assocTable = $fk->getAssociationTable();
foreach ($v->getDeleteDiff() as $r) {
$query = 'DELETE FROM ' . $assocTable->getTableName()
. ' WHERE ' . $fk->getForeign() . ' = ?'
. ' AND ' . $fk->getLocal() . ' = ?';
$this->query($r->getIncremented(), $record->getIncremented());
}
foreach ($v->getInsertDiff as $r) {
$assocRecord = $assocTable->create();
$assocRecord->set($fk->getForeign(), $r);
$assocRecord->set($fk->getLocal(), $record);
$assocRecord->save($this->conn);
}
$v->save($this->conn);
}
}
return $saveLater;
@ -199,11 +183,27 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
*/
public function saveAssociations(Doctrine_Record $record)
{
foreach ($record->getTable()->getRelations() as $rel) {
$table = $rel->getTable();
$alias = $rel->getAlias();
foreach ($record->getReferences() as $k => $v) {
$rel = $record->getTable()->getRelation($k);
if ($rel instanceof Doctrine_Relation_Association) {
$v->save($this->conn);
$assocTable = $rel->getAssociationTable();
foreach ($v->getDeleteDiff() as $r) {
$query = 'DELETE FROM ' . $assocTable->getTableName()
. ' WHERE ' . $rel->getForeign() . ' = ?'
. ' AND ' . $rel->getLocal() . ' = ?';
$this->query($r->getIncremented(), $record->getIncremented());
}
foreach ($v->getInsertDiff() as $r) {
$assocRecord = $assocTable->create();
$assocRecord->set($rel->getForeign(), $r);
$assocRecord->set($rel->getLocal(), $record);
$assocRecord->save($this->conn);
}
}
}
}
/**

View File

@ -400,11 +400,10 @@ class Doctrine_Hydrate
$rootAlias = key($this->_aliasMap);
$coll = new Doctrine_Collection($rootMap['table']);
$prev[$rootAlias] = $coll;
// we keep track of all the collections
$colls = array();
$colls[] = $coll;
$colls[] = $coll; print_r($array);
$prevRow = array();
/**
* iterate over the fetched data

View File

@ -46,49 +46,6 @@ class Doctrine_Relation_Association extends Doctrine_Relation
{
return $this->definition['assocTable'];
}
/**
* processDiff
*
* @param Doctrine_Record $record
* @param Doctrine_Connection $conn
*/
public function processDiff(Doctrine_Record $record, $conn = null)
{
if (!$conn) {
$conn = $this->getTable()->getConnection();
}
$asf = $this->getAssociationFactory();
$alias = $this->getAlias();
if ($record->hasReference($alias)) {
$new = $record->obtainReference($alias);
if ( ! $record->obtainOriginals($alias)) {
$record->loadReference($alias);
}
$operations = Doctrine_Relation::getDeleteOperations($record->obtainOriginals($alias), $new);
foreach ($operations as $r) {
$query = 'DELETE FROM ' . $asf->getTableName()
. ' WHERE ' . $this->getForeign() . ' = ?'
. ' AND ' . $this->getLocal() . ' = ?';
$conn->execute($query, array($r->getIncremented(),$record->getIncremented()));
}
$operations = Doctrine_Relation::getInsertOperations($record->obtainOriginals($alias),$new);
foreach ($operations as $r) {
$reldao = $asf->create();
$reldao->set($this->getForeign(), $r);
$reldao->set($this->getLocal(), $record);
$reldao->save($conn);
}
$record->assignOriginals($alias, clone $record->get($alias));
}
}
/**
* getRelationDql
*