diff options
author | Dries Buytaert <dries@buytaert.net> | 2001-04-12 20:30:04 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2001-04-12 20:30:04 +0000 |
commit | 13fb62454cbe569e73f95efab93e9279af08ef5d (patch) | |
tree | 61d4718771c8546b426856bd5a403a2ca0bcd351 /includes | |
parent | feba85076e6899681977d1d6fe84113600430d3e (diff) | |
download | brdo-13fb62454cbe569e73f95efab93e9279af08ef5d.tar.gz brdo-13fb62454cbe569e73f95efab93e9279af08ef5d.tar.bz2 |
- a few changes/addition to the old section code to make developing
the new section code easier: preparations as we often call it. ;)
Diffstat (limited to 'includes')
-rw-r--r-- | includes/section.inc | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/includes/section.inc b/includes/section.inc index ad25b179c..b5e825b05 100644 --- a/includes/section.inc +++ b/includes/section.inc @@ -1,5 +1,37 @@ <?php +function _section_get($field, $value) { + return db_query("SELECT * FROM section WHERE $field = '$value'"); +} + +function section_get_object($field, $value) { + return db_fetch_object(_section_get($field, $value)); +} + +function section_get_array($field, $value) { + return db_fetch_array(_section_get($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); + } +} + +function section_tree($parent = 0, $name = "", $tree = array()) { + $result = db_query("SELECT * FROM section WHERE pid = '$parent'"); + while ($section = db_fetch_object($result)) { + $tree[$section->sid] = ($name ? "$name - $section->name" : $section->name); + $tree = section_tree($section->sid, $tree[$section->sid], $tree); + } + return $tree; +} + +///// old ///// + function section_get() { $array = array(); $result = db_query("SELECT name FROM sections"); |