1
0
mirror of synced 2025-01-31 12:32:59 +03:00
This commit is contained in:
zYne 2007-04-11 18:44:23 +00:00
parent b373cb8ef7
commit 907156fd02

View File

@ -127,35 +127,41 @@ class Doctrine_Transaction extends Doctrine_Connection_Module
foreach ($this->delete as $name => $deletes) { foreach ($this->delete as $name => $deletes) {
$record = false; $record = false;
$ids = array(); $ids = array();
if (is_array($deletes[count($deletes)-1]->getTable()->getIdentifier())){
foreach($deletes as $k => $record){ if (is_array($deletes[count($deletes)-1]->getTable()->getIdentifier())) {
$cond = ''; foreach($deletes as $k => $record) {
$ids = $record->obtainIdentifier(); $cond = '';
$query = 'DELETE FROM '.$record->getTable()->getTableName().' WHERE '; $ids = $record->obtainIdentifier();
foreach(array_keys($ids) as $id){ $query = 'DELETE FROM '.$record->getTable()->getTableName().' WHERE ';
if ($cond){ $cond .= " AND ";}
$cond .= " $id = ? "; foreach(array_keys($ids) as $id ){
if ($cond) {
$cond .= " AND ";
} }
$query = $query . $cond;
$this->conn->execute($query, array_values($ids));
}
}else{
foreach ($deletes as $k => $record) {
$ids[] = $record->getIncremented();
$record->assignIdentifier(false);
}
if ($record instanceof Doctrine_Record) {
$params = substr(str_repeat("?, ",count($ids)),0,-2);
$query = 'DELETE FROM ' $cond .= " $id = ? ";
. $record->getTable()->getTableName() }
. ' WHERE '
. $record->getTable()->getIdentifier()
. ' IN(' . $params . ')';
$this->conn->execute($query, $ids); $query = $query . $cond;
} $this->conn->execute($query, array_values($ids));
} }
} else {
foreach ($deletes as $k => $record) {
$ids[] = $record->getIncremented();
$record->assignIdentifier(false);
}
if ($record instanceof Doctrine_Record) {
$params = substr(str_repeat("?, ",count($ids)),0,-2);
$query = 'DELETE FROM '
. $record->getTable()->getTableName()
. ' WHERE '
. $record->getTable()->getIdentifier()
. ' IN(' . $params . ')';
$this->conn->execute($query, $ids);
}
}
} }
$this->delete = array(); $this->delete = array();