Trouble with global scope of helper |
[eluser]Unknown[/eluser]
I couldn't find any post for my problem so that there is the problem. I'll be thankful to anyone who can help me, because I really have no idea what to do. I'm trying to list recursive tree and I made helper to walk recursive array with categories. But when I am trying to get the value inside the recursive function, I realize that this helper doesn't return any value and I got only main categories. This is my category_model Code: $q = " This is my database_helper (loaded into $autoload['model'] in config/autoload.php ) Code: function treeRecursive($id, $cat_id_array) I have tested this without Code Igniter and works perfect. Where is my mistake. Thanks in advance.
[eluser]Unknown[/eluser]
I found solution. I don't know if this is the best but it works. Helper proved works only with 'echo' or 'print' of returned value. Therefore I moved whole loop and recursion into category_view and return the array with data (from DB) through the model method. If somebody have any other idea I'll be glad to hear it.
[eluser]t'mo[/eluser]
Another idea is to try nested sets instead of parent/child relationships in your data (see also this article). There's a nice implementation of this concept on the wiki. |
Welcome Guest, Not a member yet? Register Sign In |