Welcome Guest, Not a member yet? Register   Sign In
CI Forum - get_where function for forum and topics
#12

Sorry for taking so long to reply. @jreklund yes your naming for the database stuff and the structure is clearer. I will definitely re-do mine after i learn what i wanted to do, but still as you said i can either check with if in the view, like this:

Code:
<?php
$forum_category_id = $forum["forum_category_id"];
if($category_id === $forum_category_id) {
echo "<div id='{forum_category_id}'>test";
echo "</div>";
}?>

or get the result from those 2 tables in 1 query in the model. Can you show me how to do that?

Code:
public function get_categories()
        {
            $this->db->select('*');
            $this->db->from('categories');
            $this->db->order_by('category_position', 'asc');
            $query = $this->db->get();
            return $query->result_array();

            // SELECT * FROM categories ORDER BY category_position ASC;
        }

        public function get_categories_classic()
        {
            $this->db->select('*');
            $this->db->from('categories_classic');
            $this->db->where('category_classic_category_id', 2);
            $this->db->order_by('category_classic_position', 'asc');
            $query = $this->db->get();
            return $query->result_array();
               }

My structure is the following: 
The categories classic should be contained within categories.
Categories contains ->categories_classic and categories_modern
Categories_classic -> contains forums
Categories_modern ->contains forums
Forums -> contain topics

The above code gets my categories and then it gets all the categories_classic which are equal to 2. This 2 should be the ID of categories, but i don't know how to pull the ID of categories in another function. How can i do that?

And how can i do the thing u recommended? To get all the tables - categories, categories_classic and categories modern and  check them all for their relations, and return a result. This way i won't be checking in the view.

Thanks beforehand and happy new year!
Reply


Messages In This Thread
RE: CI Forum - get_where function for forum and topics - by Knightwalker - 01-01-2018, 03:16 AM



Theme © iAndrew 2016 - Forum software by © MyBB