From 907156fd024266aebcb9dc985fb3eb009e79b8fe Mon Sep 17 00:00:00 2001 From: zYne Date: Wed, 11 Apr 2007 18:44:23 +0000 Subject: [PATCH] --- lib/Doctrine/Transaction.php | 60 ++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 27 deletions(-) diff --git a/lib/Doctrine/Transaction.php b/lib/Doctrine/Transaction.php index 8b35ef031..68d3a5aa4 100644 --- a/lib/Doctrine/Transaction.php +++ b/lib/Doctrine/Transaction.php @@ -127,35 +127,41 @@ class Doctrine_Transaction extends Doctrine_Connection_Module foreach ($this->delete as $name => $deletes) { $record = false; $ids = array(); - if (is_array($deletes[count($deletes)-1]->getTable()->getIdentifier())){ - foreach($deletes as $k => $record){ - $cond = ''; - $ids = $record->obtainIdentifier(); - $query = 'DELETE FROM '.$record->getTable()->getTableName().' WHERE '; - foreach(array_keys($ids) as $id){ - if ($cond){ $cond .= " AND ";} - $cond .= " $id = ? "; + + if (is_array($deletes[count($deletes)-1]->getTable()->getIdentifier())) { + foreach($deletes as $k => $record) { + $cond = ''; + $ids = $record->obtainIdentifier(); + $query = 'DELETE FROM '.$record->getTable()->getTableName().' WHERE '; + + 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 ' - . $record->getTable()->getTableName() - . ' WHERE ' - . $record->getTable()->getIdentifier() - . ' IN(' . $params . ')'; - $this->conn->execute($query, $ids); - } - } + $cond .= " $id = ? "; + } + + $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();