From c1115d9451fd028a434c9581567038e61f49acf7 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Mon, 10 Mar 2014 15:59:45 -0700 Subject: [ticket/12117] Add get_all_tree_data method to tree class PHPBB3-12117 --- phpBB/phpbb/tree/nestedset.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'phpBB') 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 @@ -663,6 +663,34 @@ abstract class nestedset implements \phpbb\tree\tree_interface return $parents; } + /** + * 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 * -- cgit v1.2.1 From 4127f92496c4e85a43b7813461732e0e2e739c14 Mon Sep 17 00:00:00 2001 From: Matt Friedman Date: Mon, 10 Mar 2014 16:06:53 -0700 Subject: [ticket/12117] Select all fields instead of item_basic_data PHPBB3-12117 --- phpBB/phpbb/tree/nestedset.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'phpBB') diff --git a/phpBB/phpbb/tree/nestedset.php b/phpBB/phpbb/tree/nestedset.php index c4ab3b0740..2bfb65732d 100644 --- a/phpBB/phpbb/tree/nestedset.php +++ b/phpBB/phpbb/tree/nestedset.php @@ -666,8 +666,6 @@ 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 @@ -676,7 +674,7 @@ abstract class nestedset implements \phpbb\tree\tree_interface { $rows = array(); - $sql = 'SELECT ' . implode(', ', $this->item_basic_data) . ' + $sql = 'SELECT * FROM ' . $this->table_name . ' ' . $this->get_sql_where('WHERE') . ' ORDER BY ' . $this->column_left_id . ' ' . ($order_asc ? 'ASC' : 'DESC'); -- cgit v1.2.1