Welcome Guest, Not a member yet? Register   Sign In
Active Record and JOIN
#11

[eluser]Firstrow[/eluser]
[quote author="manilodisan" date="1225386891"][quote author="OES" date="1225385832"]Yep sorry was not thinking straight there.

why dont you then just perform 2 queries to post to the page.

One for the Article and other for comments.

good Luck[/quote]

And when you have 1000 articles?

1000 = how many queries?

Code:
$articles =         array ();

foreach ( $query->result () as $row )
{
    $articles [ $row->article_id ] [ 'title' ] = $row->article_title;
    $articles [ $row->article_id ] [ 'content' ] = $row->article_content;
    $articles [ $row->article_id ] [ 'comments' ] [] = array ( 'coment_id' => $row->comment_id, 'coment_text' => $row->coment_text );
}

echo '<pre>' . print_r ( $articles, TRUE ) . '</pre>';
[/quote]


I think its better use 2 requests =)
#12

[eluser]OES[/eluser]
I only said if it was one article :-).

Lee
#13

[eluser]manilodisan[/eluser]
The trick is to balance the load between the database and other services (like scripting). Of course it would work with both examples. It all goes down to that profiler Smile and the time taken for a page to load, and of course, your willing to perfect your coding skills.




Theme © iAndrew 2016 - Forum software by © MyBB