From: Andrey Kutejko Date: Thu, 4 Jul 2013 16:52:06 +0000 (+0300) Subject: composite key in fixtures X-Git-Tag: 0.5~191 X-Git-Url: https://git.andy128k.dev/?a=commitdiff_plain;h=2652bdb7de24d1a7960ba46c97e34f09d226cad7;p=ipf.git composite key in fixtures --- 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