From 2652bdb7de24d1a7960ba46c97e34f09d226cad7 Mon Sep 17 00:00:00 2001 From: Andrey Kutejko Date: Thu, 4 Jul 2013 19:52:06 +0300 Subject: [PATCH] composite key in fixtures --- ipf/command/fixtures.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ipf/command/fixtures.php b/ipf/command/fixtures.php index c350163..edcf8c4 100644 --- a/ipf/command/fixtures.php +++ b/ipf/command/fixtures.php @@ -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 -- 2.49.0