CodeIgniter Forums
Too many db 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: Too many db queries (/showthread.php?tid=45518)



Too many db queries - El Forum - 09-24-2011

[eluser]Haskabab[/eluser]
What's up!

I'm building a browser game with codeigniter, and I've tried to organize the many functions of my game into their categorized library. But many libraries make use of each other.

I have my Character library, with the function get( $id )

And i have (22+) other libraries, for example:

Stats library, also with a lot of functions; like heal / damage etc..
Inventory
etc...

And all these libraries need the character information in order to know how to proceed, so my character->get() function gets called 22 times each time i load a page!

So that's 22 queries pulling the exact same data.

Now my question is, is there any way to reduce the amount of queries without storing the database information in a session or in a variable somewhere in codeigniter, since this information is updated every time you refresh the page and it's essential the exact same data from the database is displayed.