diff options
author | Matt Friedman <maf675@gmail.com> | 2014-03-10 15:59:45 -0700 |
---|---|---|
committer | Matt Friedman <maf675@gmail.com> | 2014-03-10 15:59:45 -0700 |
commit | c1115d9451fd028a434c9581567038e61f49acf7 (patch) | |
tree | f62a7836d62475ec74f3c4511b6a8c0bb845bd98 /phpBB/phpbb/tree | |
parent | c169583dc3c551bc08fc217e0d5bb5dd6022ec57 (diff) | |
download | forums-c1115d9451fd028a434c9581567038e61f49acf7.tar forums-c1115d9451fd028a434c9581567038e61f49acf7.tar.gz forums-c1115d9451fd028a434c9581567038e61f49acf7.tar.bz2 forums-c1115d9451fd028a434c9581567038e61f49acf7.tar.xz forums-c1115d9451fd028a434c9581567038e61f49acf7.zip |
[ticket/12117] Add get_all_tree_data method to tree class
PHPBB3-12117
Diffstat (limited to 'phpBB/phpbb/tree')
-rw-r--r-- | phpBB/phpbb/tree/nestedset.php | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/phpBB/phpbb/tree/nestedset.php b/phpBB/phpbb/tree/nestedset.php index 13184cf41c..c4ab3b0740 100644 --- a/phpBB/phpbb/tree/nestedset.php +++ b/phpBB/phpbb/tree/nestedset.php @@ -664,6 +664,34 @@ abstract class nestedset implements \phpbb\tree\tree_interface } /** + * Get all items from the tree + * + * Basic data is defined in the $item_basic_data property. + * + * @param bool $order_asc Order the items ascending by their left_id + * @return array Array of items (containing all columns from the item table) + * ID => Item data + */ + public function get_all_tree_data($order_asc = true) + { + $rows = array(); + + $sql = 'SELECT ' . implode(', ', $this->item_basic_data) . ' + FROM ' . $this->table_name . ' ' . + $this->get_sql_where('WHERE') . ' + ORDER BY ' . $this->column_left_id . ' ' . ($order_asc ? 'ASC' : 'DESC'); + $result = $this->db->sql_query($sql); + + while ($row = $this->db->sql_fetchrow($result)) + { + $rows[(int) $row[$this->column_item_id]] = $row; + } + $this->db->sql_freeresult($result); + + return $rows; + } + + /** * Remove a subset from the nested set * * @param array $subset_items Subset of items to remove |