diff options
author | Nathan Guse <nathaniel.guse@gmail.com> | 2014-03-10 21:30:39 -0500 |
---|---|---|
committer | Nathan Guse <nathaniel.guse@gmail.com> | 2014-03-10 21:30:39 -0500 |
commit | 92b638ed83e5d66fdcb1d18914aab9495d1a6aea (patch) | |
tree | 4f551261b4a2ccf4bf452a9148420682148a0561 /phpBB | |
parent | 23ea83342556ed16215513b877a9c90ace186257 (diff) | |
parent | 4127f92496c4e85a43b7813461732e0e2e739c14 (diff) | |
download | forums-92b638ed83e5d66fdcb1d18914aab9495d1a6aea.tar forums-92b638ed83e5d66fdcb1d18914aab9495d1a6aea.tar.gz forums-92b638ed83e5d66fdcb1d18914aab9495d1a6aea.tar.bz2 forums-92b638ed83e5d66fdcb1d18914aab9495d1a6aea.tar.xz forums-92b638ed83e5d66fdcb1d18914aab9495d1a6aea.zip |
Merge pull request #2107 from VSEphpbb/ticket/12117
[ticket/12117] Add get_all_tree_data method to tree class
Diffstat (limited to 'phpBB')
-rw-r--r-- | phpBB/phpbb/tree/nestedset.php | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/phpBB/phpbb/tree/nestedset.php b/phpBB/phpbb/tree/nestedset.php index 13184cf41c..2bfb65732d 100644 --- a/phpBB/phpbb/tree/nestedset.php +++ b/phpBB/phpbb/tree/nestedset.php @@ -664,6 +664,32 @@ abstract class nestedset implements \phpbb\tree\tree_interface } /** + * Get all items from the tree + * + * @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 * + 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 |