diff options
author | Dries Buytaert <dries@buytaert.net> | 2001-04-13 08:27:32 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2001-04-13 08:27:32 +0000 |
commit | b87d482b38dd68dfcaf97bc94a6b7ea833117240 (patch) | |
tree | 1ef4f03e691b98455ddce91dfa71e1935e9200dc /includes | |
parent | c1770795e4b8f77f2ebd1f3c1acbb556a751e1fb (diff) | |
download | brdo-b87d482b38dd68dfcaf97bc94a6b7ea833117240.tar.gz brdo-b87d482b38dd68dfcaf97bc94a6b7ea833117240.tar.bz2 |
Last nights updates (under construction):
- added _type() hook so each module can return the content types he/she
implements
Diffstat (limited to 'includes')
-rw-r--r-- | includes/database.inc | 6 | ||||
-rw-r--r-- | includes/section.inc | 13 |
2 files changed, 11 insertions, 8 deletions
diff --git a/includes/database.inc b/includes/database.inc index 30b1c5a1f..139dee1b4 100644 --- a/includes/database.inc +++ b/includes/database.inc @@ -6,8 +6,10 @@ function db_connect($host, $user, $pass, $name) { // NOTE: we are using a persistent connection! } -function db_query($query) { - if ($result = mysql_query($query)) return $result; +function db_query($query, $debug = 0) { + $result = mysql_query($query); + if ($debug) print "<P>query: $query<BR>error". mysql_error() ."</P>"; + if ($result) return $result; else watchdog("error", "database: ". mysql_error() ."<BR>query: ". htmlspecialchars($query)); } diff --git a/includes/section.inc b/includes/section.inc index b5e825b05..6ed1d4030 100644 --- a/includes/section.inc +++ b/includes/section.inc @@ -13,12 +13,13 @@ function section_get_array($field, $value) { } function section_save($edit) { - if ($edit["sid"]) { // ? - db_query("UPDATE section SET name = '". check_input($edit[name]) ."', pid = '". check_input($edit[pid]) ."' WHERE sid = $edit[sid]", 1); - } - else { - db_query("INSERT INTO section (name, pid) VALUES ('". check_input($edit[name])."', '". check_input($edit[pid]) ."')", 1); - } + if ($edit["sid"]) db_query("UPDATE section SET name = '". check_input($edit[name]) ."', pid = '". check_input($edit[pid]) ."' WHERE sid = $edit[sid]", 1); + else db_query("INSERT INTO section (name, pid) VALUES ('". check_input($edit[name])."', '". check_input($edit[pid]) ."')", 1); + + $sid = ($edit[sid] ? $edit[sid] : db_insert_id()); + + db_query("DELETE FROM section_type WHERE sid = '$sid'", 1); + foreach ($edit[type] as $key=>$type) db_query("INSERT INTO section_type (sid, type) VALUES ('". check_input($sid) ."', '". check_input($type) ."')", 1); } function section_tree($parent = 0, $name = "", $tree = array()) { |