Welcome Guest, Not a member yet? Register   Sign In
How to get correct Number of Comments (with 4 connected tables: Art./Cat./Users/Comm.)
#2

[eluser]quibstar[/eluser]
I'm having pretty much the same issues,but instead of categories I have tags...I'm new to CI so be kind.

The issue is getting the comment count. I actually made this work in procedural PHP, but don't know how to port it over to code igniter. I nested two query inside of the initial query to get comments and tags:

Initial query:
Code:
$q = "SELECT user_id,blog, blog, blog, date_format(blog.date,'%Y %d %M ') AS date, first_name, last_name,time_stamp FROM blog INNER JOIN users USING ( user_id ) ORDER BY time_stamp DESC, time_stamp DESC LIMIT $start, $display";

Here is a snippet of getting the comments:
Code:
$q1 = "SELECT COUNT(blog) FROM blog_comment WHERE blog =" . $row['blog'] .  " AND submit ='approved'  ";

and here is a snippet of getting the tags:
Code:
$q2 = "SELECT * FROM blogtagjoin inner join tags USING(tag_id) WHERE blog=" . $row['blog'] .  "  ";

what needs to be done in CI is to run the queries withing the first query. I don't know enough about CI yet to figure this out...can you use a helper? or maybe a custom function?

Any help appreciated.


Messages In This Thread
How to get correct Number of Comments (with 4 connected tables: Art./Cat./Users/Comm.) - by El Forum - 07-24-2009, 08:53 AM



Theme © iAndrew 2016 - Forum software by © MyBB