How can I make few global php functions
which can be called from any Joomla custom module
?
E.g I wish to make a global function executing a select database query:
function select($row,$table_name,$where,$equals) {
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($row)
->from($db->quoteName($table_name))
->where($db->quoteName($where) . "=" . $db->q($equals));
$db->setQuery($query);
$result = $db->loadResult();
$row = $db->loadAssoc();
return $row[$row];
}
and then call it from any module:
$result = select('id','#__table','name','john');
what would be the best way to achieve this?