From c4a4586931a62f9bdef2bc0f58796f096fc7e9e5 Mon Sep 17 00:00:00 2001 From: Andrey Kutejko Date: Sun, 11 Aug 2013 14:23:18 +0300 Subject: [PATCH] minor simplifications --- ipf/command/fixtures.php | 15 ++++++++++----- ipf/form/field.php | 11 +++++------ 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/ipf/command/fixtures.php b/ipf/command/fixtures.php index 22266da..0cc2c9c 100644 --- a/ipf/command/fixtures.php +++ b/ipf/command/fixtures.php @@ -36,14 +36,19 @@ class IPF_Command_Fixtures echo "Loading $modelClass "; $table = IPF_ORM::getTable($modelClass); $table->getConnection()->beginTransaction(); + + $query = $table + ->createQuery() + ->limit(1); + foreach ($key as $k) + $query->addWhere($k . ' = ?'); + foreach ($records as $record) { - $query = $table - ->createQuery() - ->limit(1); + $params = array(); foreach ($key as $k) - $query->addWhere($k . ' = ?', array($record[$k])); + $params[] = $record[$k]; - $model = $query->execute(); + $model = $query->execute($params); if ($model) $model = $model[0]; else diff --git a/ipf/form/field.php b/ipf/form/field.php index bd87d67..85d225f 100644 --- a/ipf/form/field.php +++ b/ipf/form/field.php @@ -17,19 +17,18 @@ class IPF_Form_Field function __construct($params=array()) { + $widget_attrs = ArrayTools::pop($params, 'widget_attrs', array()); + $default = array(); foreach ($params as $key=>$in) { - if ($key !== 'widget_attrs') - if (isset($this->$key)) - $default[$key] = $this->$key; + if (isset($this->$key)) + $default[$key] = $this->$key; } $m = array_merge($default, $params); foreach ($params as $key=>$in) { - if ($key !== 'widget_attrs') - $this->$key = $m[$key]; + $this->$key = $m[$key]; } - $widget_attrs = isset($params['widget_attrs']) ? $params['widget_attrs'] : array(); $this->widget = $this->createWidget($widget_attrs); } -- 2.49.0