From 990b708dff0c9eca3d576a890e962c4dd40226c8 Mon Sep 17 00:00:00 2001 From: Kevin Chabowski Date: Wed, 5 Oct 2011 15:18:23 +0200 Subject: Fixed some bugs in db.php and models.php. --- ratatoeskr/sys/db.php | 2 +- ratatoeskr/sys/models.php | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) (limited to 'ratatoeskr/sys') diff --git a/ratatoeskr/sys/db.php b/ratatoeskr/sys/db.php index 55801c0..e5caddc 100644 --- a/ratatoeskr/sys/db.php +++ b/ratatoeskr/sys/db.php @@ -73,7 +73,7 @@ function qdb_vfmt($args) */ function qdb_fmt() { - return qdb_vfmt(fung_get_args()); + return qdb_vfmt(func_get_args()); } /* diff --git a/ratatoeskr/sys/models.php b/ratatoeskr/sys/models.php index eb8f26c..0ec4111 100644 --- a/ratatoeskr/sys/models.php +++ b/ratatoeskr/sys/models.php @@ -984,7 +984,7 @@ class Style */ public static function by_id($id) { - $obj = new seld; + $obj = new self; $obj->populate_by_sqlresult(qdb("SELECT `id`, `name`, `code` FROM `PREFIX_styles` WHERE `id` = %d", $id)); return $obj; } @@ -1183,9 +1183,18 @@ class Section $this->name = $sqlrow["name"]; $this->title = Multilingual::by_id($sqlrow["title"]); $this->template = $sqlrow["template"]; - $this->styles = array_filter_empty(array_map( - function($id) { try{return Style::by_id($id);}catch(DoesNotExistError $e){ return "";} }, - array_filter_empty(explode("+", $sqlrow["styles"])))); + $this->styles = array(); + foreach(explode("+", $sqlrow["styles"]) as $style_id) + { + if(!empty($style_id)) + { + try + { + $this->styles[] = Style::by_id($style_id); + } + catch(DoesNotExistError $e) { } + } + } } /* @@ -1285,7 +1294,7 @@ class Section $this->title->save(); qdb("UPDATE `PREFIX_sections` SET `name` = '%s', `title` = %d, `template` = '%s', `styles` = '%s' WHERE `id` = %d", - $this->name, $this->title->get_id(), $this->template, $styles); + $this->name, $this->title->get_id(), $this->template, $styles, $this->id); } /* -- cgit v1.2.3-70-g09d2