1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-31 22:10:45 +02:00

Merge pull request #2107 from VSEphpbb/ticket/12117

[ticket/12117] Add get_all_tree_data method to tree class
This commit is contained in:
Nathan Guse
2014-03-10 21:30:39 -05:00
2 changed files with 42 additions and 0 deletions

View File

@@ -663,6 +663,32 @@ abstract class nestedset implements \phpbb\tree\tree_interface
return $parents;
}
/**
* 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
*