Author: mcantelon
Date: Thu Jan  5 16:55:01 2012
New Revision: 10578

Log:
Added methods to import class to create or fetch terms.

Modified:
   trunk/lib/QubitFlatfileImport.class.php

Modified: trunk/lib/QubitFlatfileImport.class.php
==============================================================================
--- trunk/lib/QubitFlatfileImport.class.php     Thu Jan  5 14:26:54 2012        
(r10577)
+++ trunk/lib/QubitFlatfileImport.class.php     Thu Jan  5 16:55:01 2012        
(r10578)
@@ -360,7 +360,7 @@
 
   public function createOrFetchActor($name, $history = false)
   {
-    $query = "SELECT id FROM actor_i18n WHERE authorized_form_of_name=?";
+    $query = "SELECT * FROM actor_i18n WHERE authorized_form_of_name=?";
     $statement = $this->sqlQuery($query, array($name));
     $result = $statement->fetch(PDO::FETCH_OBJ);
     if ($result)
@@ -371,6 +371,30 @@
     }
   }
 
+  public function createOrFetchTerm($taxonomyId, $name, $culture = 'en')
+  {
+    $query = "SELECT * FROM term t LEFT JOIN term_i18n ti ON t.id=ti.id \r
+      WHERE t.taxonomy_id=? AND ti.name=? AND ti.culture=?";
+    $statement = $this->sqlQuery($query, array($taxonomyId, $name, $culture));
+    $result = $statement->fetch(PDO::FETCH_OBJ);
+    if ($result)
+    {
+      return $result;
+    } else {
+      return $this->createTerm($taxonomyId, $name, $culture);
+    }
+  }
+
+  public function createTerm($taxonomyId, $name, $culture = 'en')
+  {
+    $term = new QubitTerm;
+    $term->name = $name;
+    $term->taxonomyId = $taxonomyId;
+    $term->save();
+
+    return $term;
+  }
+
   public function createActor($name, $history = false)
   {
     $actor = new QubitActor;

-- 
You received this message because you are subscribed to the Google Groups 
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/qubit-commits?hl=en.

Reply via email to