dongzhuo5185 2011-10-01 10:58
浏览 52

codeigniter mysql查询到多维数组(嵌套列表)[关闭]

Ok here is what I am struggling with.

I have drop down menu on my site which is basically a nested list. It gets its information from my database. Now I have made this work as a procedural piece of code but I am now trying to separate it out for a MVC framework. Now my thinking is that if I use the model to get the information from the table pass that on to the controller as an multidimensional array and the pass it out to the view where I will then access the array to fill out the list. I need (or think I do) do it this way so that when I create another view for mobile devices I can reformat it to suit.

Down to the nitty gritty.

*table 'sch_cat'*

sch_cat_uid (primery{parent id}),

sch_cat_id,

sch_cat_order,

sch_cat_name.

table sch_subcat

sch_subcat_uid,

sch_subcat_order,

sch_subcat_name,

sch_subcat_href.

sch_subcat_parent (reference 'shc_cat_uid' from table 'sch_cat' )

The main focus here is putting the information to the array but I really don'y know where to begin here so any and pointers appreciated oh and if I am well of base don't feel shy in calling me a plumb!.

Cheers Troy

  • 写回答

1条回答 默认 最新

  • douyang5943 2011-10-01 12:29
    关注

    Have you looked into using CodeIgniters Active Record class?

    As for querying data from a database with the class, you can easily make it come back the way you're looking for, I believe the particular function you're looking for is result_array().

    Regarding the MVC practice, it's sufficient to have the querying of these items be in a model, that the controller grabs and passes to the proper view.

    评论

报告相同问题?