From ced00d51e39f2924ba98451673ca69bcf5fb52ac Mon Sep 17 00:00:00 2001 From: Silvio Date: Wed, 17 Nov 2010 17:19:14 -0200 Subject: Avoiding duplicate entries at addManyToManyEntities() by looking into the database --- lib/sfIsisImporterRelations.class.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/sfIsisImporterRelations.class.php b/lib/sfIsisImporterRelations.class.php index 248bf99..49ec9f2 100644 --- a/lib/sfIsisImporterRelations.class.php +++ b/lib/sfIsisImporterRelations.class.php @@ -151,14 +151,13 @@ class sfIsisImporterRelations extends sfIsisImporterEntities { */ public function addManyToManyEntities(&$model, array $values, $relation, $key = 'name') { - $existing = array(); - foreach ($values as $value) { + $existing = $this->getEntity($relation, $value, $key); + // Prevent duplicate entries. - if (!in_array($value, $existing)) + if (!$existing) { - $existing[] = $value; $this->addManyToMany($model, $value, $relation, $key); } else { -- cgit v1.2.3