Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8683075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:56:46+00:00 2026-06-12T21:56:46+00:00

Model: I have a table like id:name:parentId. The parentId references to the id. Simple

  • 0

Model: I have a table like id:name:parentId. The parentId references
to the id. Simple recursion to build a tree.

In example:

  1. 1:root:null
  2. 2:Heading1:1
  3. 3:Heading2:1
  4. 4:subheading1.1:2

In my controller I would now call the Database and pass the data
through to the view. If I would do that then I would have a function
inside my view. I do not like functionality in my view :).

The other approach would be to sort that somehow. But would this really make a difference?

  • For doing that I would have to use helping fields to know which level I am in. So I could iterate over the sorted array.
  • Or the other approach: Multidimensional arrays. Maybe pointless because I have no idea how deep that tree is going to be.

Would be thankful for any recommendations.
Thanks in advance.

edit: im receiving the data as objects.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T21:56:47+00:00Added an answer on June 12, 2026 at 9:56 pm

    According to the trends in MVC framework based designs (fat model, slim controller), I would recommend to use your Model to fetch the data and deliver a nested data set (a mulitidimensional array) to the controller/view. It doesn’t matter how deep the hierarchy will be, it will be finite.

    As the question is a bit broadly asked, it’s not clear what sort of data it is, neither whether you’re always going to need the whole data at once or just some relative chunk of it. Either way I suppose you’d like to keep the hierarchy, so if you’re not comfortable iterating through nested arrays there’s always the alternative of using (Std)Objects.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table like this: Name Tree Iron Clay Added I want to
I got a simple problem in SQLAlchemy. I have one model in a table,
I have a simple ActiveRecord model called Student with 100 records in the table.
dear all..i have a table it looks like: Name version DDX 01 DTX 05
I want to have a general product model that has basic info like name,
So I have a table people which is like this Id Name 1 John
I have a table that will display the name of camera and its model.
I have a table like: @foreach (var item in Model) { <tr> <td> @Html.DisplayFor(modelItem
I have a Departments reference table like: Id Name 1. Dept1 2. Dept2 3.
I have product_details table which belongs to categories. product_details has fields like id, name,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.