]> git.andy128k.dev Git - ipf.git/commitdiff
composite key in fixtures
authorAndrey Kutejko <andy128k@gmail.com>
Thu, 4 Jul 2013 16:52:06 +0000 (19:52 +0300)
committerAndrey Kutejko <andy128k@gmail.com>
Thu, 4 Jul 2013 16:52:06 +0000 (19:52 +0300)
ipf/command/fixtures.php

index c350163ff4aef1dbd3dd2f78f2eaa58cb50ae9ef..edcf8c4c0117e881fbd579ad1b1b34fc001d30fe 100644 (file)
@@ -32,15 +32,18 @@ class IPF_Command_Fixtures
         foreach ($fixtures as $fixture) {
             $modelClass = $fixture['model'];
             $key = $fixture['key'];
+            if (!is_array($key))
+                $key = array($key);
             $records = $fixture['records'];
             echo "Loading $modelClass ";
             foreach ($records as $record) {
-                $model = IPF_ORM::getTable($modelClass)
+                $query = IPF_ORM::getTable($modelClass)
                     ->createQuery()
-                    ->where($key . ' = ?', array($record[$key]))
-                    ->limit(1)
-                    ->execute();
+                    ->limit(1);
+                foreach ($key as $k)
+                    $query->where($k . ' = ?', array($record[$k]));
 
+                $model = $query->execute();
                 if ($model)
                     $model = $model[0];
                 else