This commit is contained in:
parent
827755afd3
commit
2291272ebf
@ -492,7 +492,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
|
|||||||
|
|
||||||
// prepare and execute the statement
|
// prepare and execute the statement
|
||||||
$this->execute($query, array_values($values));
|
$this->execute($query, array_values($values));
|
||||||
|
print $query . '(' . implode(', ', $values) . ")<br>";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -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;
|
return $saveLater;
|
||||||
@ -199,11 +183,27 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module
|
|||||||
*/
|
*/
|
||||||
public function saveAssociations(Doctrine_Record $record)
|
public function saveAssociations(Doctrine_Record $record)
|
||||||
{
|
{
|
||||||
foreach ($record->getTable()->getRelations() as $rel) {
|
foreach ($record->getReferences() as $k => $v) {
|
||||||
$table = $rel->getTable();
|
$rel = $record->getTable()->getRelation($k);
|
||||||
$alias = $rel->getAlias();
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -400,11 +400,10 @@ class Doctrine_Hydrate
|
|||||||
$rootAlias = key($this->_aliasMap);
|
$rootAlias = key($this->_aliasMap);
|
||||||
$coll = new Doctrine_Collection($rootMap['table']);
|
$coll = new Doctrine_Collection($rootMap['table']);
|
||||||
$prev[$rootAlias] = $coll;
|
$prev[$rootAlias] = $coll;
|
||||||
|
|
||||||
// we keep track of all the collections
|
// we keep track of all the collections
|
||||||
$colls = array();
|
$colls = array();
|
||||||
$colls[] = $coll;
|
$colls[] = $coll; print_r($array);
|
||||||
|
|
||||||
$prevRow = array();
|
$prevRow = array();
|
||||||
/**
|
/**
|
||||||
* iterate over the fetched data
|
* iterate over the fetched data
|
||||||
|
@ -46,49 +46,6 @@ class Doctrine_Relation_Association extends Doctrine_Relation
|
|||||||
{
|
{
|
||||||
return $this->definition['assocTable'];
|
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
|
* getRelationDql
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user