Logical Problem With category and sub-category - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Logical Problem With category and sub-category (/showthread.php?tid=18066) |
Logical Problem With category and sub-category - El Forum - 04-24-2009 [eluser]woomacoder[/eluser] Hello Everybody, I have a problem (logical problem) with Managed my category and subcategory database; the code is it: Code: public function GetCats($UriString) INCAZUS is my personal word to identified a right status, where code works! I have two table: CATS table, with id, sub_cat (counter of subcategory), name and some values. SUBCATS table, with id, parent cat id (for related subcategory with father's category) and some values. But... php print_r reports: Code: CI_DB_mysql_result Object ( [conn_id] => Resource id #28 [result_id] => Resource id #48 [result_array] => Array ( ) [result_object] => Array ( [0] => stdClass Object ( [cat_id] => 6 [sub_cats] => 0 [cat_name] => Prova dopo ciclo [cat_end] => 2009-04-24 12:51:01 [cat_warning] => 0000-00-00 00:00:00 [cat_class] => B [cat_completed] => 0 ) ) [current_row] => 0 [num_rows] => 1 [row_data] => ) The code pass the latest value of the CATS table!!! Why? Where is the error? Thanks and sorry for bad english Logical Problem With category and sub-category - El Forum - 04-24-2009 [eluser]woomacoder[/eluser] Nothing? Logical Problem With category and sub-category - El Forum - 04-24-2009 [eluser]Dam1an[/eluser] Firstly, you can't always assume people will get back to you immediatly, so wait more then 4 and a half hours before bumping the thread Secondly, what exactly is the relcats table, you only mention the cats and subcats tables in your post On a side note, can you not just have all this in a single table, with id, parent_id, name, etc... Also, can you try explain a bit more exactly what you're trying to acheive Also, you might be getting a nameing conflict, as you have $DataSet in the outer loop, and then assigning another result to it (but will then carry on with the outer loop again) Logical Problem With category and sub-category - El Forum - 04-24-2009 [eluser]woomacoder[/eluser] [quote author="Dam1an" date="1240610836"]Firstly, you can't always assume people will get back to you immediatly, so wait more then 4 and a half hours before bumping the thread Secondly, what exactly is the relcats table, you only mention the cats and subcats tables in your post On a side note, can you not just have all this in a single table, with id, parent_id, name, etc... Also, can you try explain a bit more exactly what you're trying to acheive Also, you might be getting a nameing conflict, as you have $DataSet in the outer loop, and then assigning another result to it (but will then carry on with the outer loop again)[/quote] Thank's for reply; sorry form my hasty... I Have two table: CATS and SUBCATS; I wanna extract all records of cats and ONLY records of SUBCATS that related with CATS; example: cats contain: ID NAME SUBCATS 1 A 0 2 B 2 (contains 2 subcategories) subcats contain: ID ID_CAT NAME 1 2(id of cats) SUBA 2 2 SUBB I wanna extract all and printout that: A B -- SUBA -- SUBB [...] Logical Problem With category and sub-category - El Forum - 04-24-2009 [eluser]Dam1an[/eluser] I still don't see the point of storing the number of sub categories in the cats table, as you risk getting out of sync, and its very quick to do a count on the number of records where parent_id == cat_id Could you not do something like Code: <?php Logical Problem With category and sub-category - El Forum - 04-24-2009 [eluser]Eric Barnes[/eluser] I agree with Dam1an. No need in having two separate tables for categories like this. A parent_id column will allow you to access any depth from the one table. Logical Problem With category and sub-category - El Forum - 04-25-2009 [eluser]woomacoder[/eluser] [quote author="Dam1an" date="1240616391"]I still don't see the point of storing the number of sub categories in the cats table, as you risk getting out of sync, and its very quick to do a count on the number of records where parent_id == cat_id Could you not do something like Code: <?php Yeah! Great solution! thank you! Logical Problem With category and sub-category - El Forum - 09-10-2009 [eluser]brandingdavid[/eluser] So, where does this go? I am trying to use it, and get: Call to a member function on a non-object Code is nearly identical... Anyone have any tips? Logical Problem With category and sub-category - El Forum - 09-10-2009 [eluser]brandingdavid[/eluser] Trying to show a category tree (with subcats and sub-subcats) Using this code: Code: <?php Getting: Fatal error: Call to a member function on a non-object in /home/domains/public_html/system/application/views/frontpage_view.php on line 25 Anyone have any ideas why I am having this problem? Logical Problem With category and sub-category - El Forum - 09-10-2009 [eluser]jedd[/eluser] Hi brandingdavid and welcome to the CI forums. It'd be helpful if you'd post the file that is actually giving you the error - the view file, in this case, as per the error message in your post. Also handy if you show the controller code around the area where you load the view. |