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

(This post was last modified: 01-01-2018, 06:18 AM by jreklund.)

What's the actual goal of your database structure? So that you can re-use forum(s) inside multiple categories (with different layouts)?
If that's the case a structure like this would be much more sense. Because your database dump dosen't contain a link between classic/modern and categories.
https://pastebin.com/WnrcWc4D

Categories = All categories, position and layout (modern/classic)
Forums = Forums
Layouts = Maps what forum goes into what category and in what order (position)
Note: position_id inside layouts should be layouts_id.
____________________________________________

You can pass plain SQL queries with this, it's faster then using the query builder. That's regarding the first database structure not the last one I did.
PHP Code:
$this->db->query("SELECT `forums`.`category_id`, `categories`.`category_title`, `categories`.`category_layout`, `forums`.`forum_id`, `forums`.`forum_image`, `forums`.`forum_title`, `forums`.`forum_description` FROM `forums` INNER JOIN `categories` ON `forums`.`category_id`=`categories`.`category_id` ORDER BY `categories`.`category_position` ASC, `forums`.`forum_position` ASC
"
)->result(); 

This should be the same, but slower.
PHP Code:
$this->db->select('`forums`.`category_id`, `categories`.`category_title`, `categories`.`category_layout`, `forums`.`forum_id`, `forums`.`forum_image`, `forums`.`forum_title`, `forums`.`forum_description`')
    ->
from('forums')
    ->
join('categories','`forums`.`category_id`=`categories`.`category_id`','inner')
    ->
order_by('`categories`.`category_position`','ASC')
    ->
order_by('`forums`.`forum_position`','ASC')
->
get()
->
result(); 
Reply


Messages In This Thread
RE: CI Forum - get_where function for forum and topics - by jreklund - 01-01-2018, 06:15 AM



Theme © iAndrew 2016 - Forum software by © MyBB