I am working on a Joomla based application and earlier I was using innumerable database queries in modules and some of them are the same and repeatable due to availability on different pages.
To get rid off the same repeatable queries and reduce the database load, I have built a helper file in system plugin and put all custom queries in separate function within a single class. The all queries count is around 40.
But in each function, I have to call the below code to run the query:
Code: Select all
$user = JFactory::getUser();
$userid = $user->get('id');
$db = JFactory::getDbo();
Now I want to ask, Is this practice is ok as the Joomla API framework is already loaded and I can call the above APIs innumerable times in each function?
OR
How can I use the single instances of these APIs in helper class, if it is possible how to use it and where to use it?