![]() |
DataMapper: Too many queries. - 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: DataMapper: Too many queries. (/showthread.php?tid=47761) |
DataMapper: Too many queries. - El Forum - 12-21-2011 [eluser]scherman[/eluser] Hi people, i am developing a website, and i've just started with the Datamapper. I have "Articles" and "Authors". The articles have one author, and the authors have one or more articles. The problem is: I want to show an article's list with their authors. Like: Id: Article1->id Name: Article1->title Author: Article1->author->name I do the next: Controller Code: $article = new Article(); View Code: <h1>Count: <?php echo $articles->count(); ?></h1> but it generate a lot of queries: - 1 query for the count() - 1 query for the get() - 1 query for each relation article-author Is there any way to make it better with less queries? Because if i have 10 articles there'll be no problem, but if i'd have 10.000 articles, it'd very slowly! And it is possible to make it with only one query if i write it. Sorry for my english, i hope you can help me =) |