diff options
author | Silvio <silvio@devlet.com.br> | 2010-11-17 17:19:14 -0200 |
---|---|---|
committer | Silvio <silvio@devlet.com.br> | 2010-11-17 17:19:14 -0200 |
commit | ced00d51e39f2924ba98451673ca69bcf5fb52ac (patch) | |
tree | 79beefcf0c0ab2c3115154eb8dfd197d01ccda05 | |
parent | b549a90ac492bca7c6915d66db5677f2b9016def (diff) | |
download | sf_isis_importer_plugin-ced00d51e39f2924ba98451673ca69bcf5fb52ac.tar.gz sf_isis_importer_plugin-ced00d51e39f2924ba98451673ca69bcf5fb52ac.tar.bz2 |
Avoiding duplicate entries at addManyToManyEntities() by looking into the database
-rw-r--r-- | lib/sfIsisImporterRelations.class.php | 7 |
1 files changed, 3 insertions, 4 deletions
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 { |