diff --git a/include/class.orm.php b/include/class.orm.php index de47d422ecf6b2290e8541b5476d2a54f1d3cdbb..38d3482daf79c91fddeb9ef0f9b81240d4a4ed42 100644 --- a/include/class.orm.php +++ b/include/class.orm.php @@ -160,16 +160,18 @@ class VerySimpleModel { $filter = $fields = array(); if (count($this->dirty) === 0) return; - foreach ($this->dirty as $field=>$old) - if ($this->__new__ or !in_array($field, $pk)) + foreach ($this->dirty as $field=>$old) { + if ($this->__new__ or !in_array($field, $pk)) { if (@get_class($this->get($field)) == 'SqlFunction') $fields[] = $field.' = '.$this->get($field)->toSql(); else $fields[] = $field.' = '.db_input($this->get($field)); - foreach ($pk as $p) - $filter[] = $p.' = '.db_input($this->get($p)); + } + } $sql .= ' SET '.implode(', ', $fields); if (!$this->__new__) { + foreach ($pk as $p) + $filter[] = $p.' = '.db_input($this->get($p)); $sql .= ' WHERE '.implode(' AND ', $filter); $sql .= ' LIMIT 1'; }