Location: PHPKode > projects > Chalange > com_chalange/helpers/parms.php
<?php
/*
 * @component SQL 2 Excel Component
 * @copyright Copyright (C) Joomla-R-Us, joomla-r-us.com
 * @license http://www.gnu.org/licenses/gpl-3.0.html GNU/GPLv3
 */

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

class Sql2excelParms
{		
	function getParms()
	{
		$parms = new stdClass();	

		// Get the settings from the #__sql2excel_settings 
		$pdb	= & JFactory::getDBO(); 
		$query =  'SELECT param,value FROM #__sql2excel_settings';
		$pdb->setQuery($query);
		$res = $pdb->loadObjectList();

		// Add to new Object
		if ( $pdb->getErrorNum() == 0 ) {
			foreach ( $res as $row ) {
				$key = $row->param;
				$parms->$key = $row->value;
			}
		}
		return $parms;		
	}

	
	function get($cmpParms, $key, $default_value)
	{
		
		if ( !is_object($cmpParms) ) {
			$cmpParms = Sql2excelParms::getParms();
		}
		
		if ( isset($cmpParms->$key) ) {
			return $cmpParms->$key;
		} else {
			$db	= & JFactory::getDBO(); 
			$query	=  'INSERT INTO #__sql2excel_settings (`param`,`value`) VALUES (' . $db->Quote($key) . ',' . $db->Quote($default_value) . ')';
			$db->setQuery($query);
			$db->query();
			return $default_value;
		}
	}
	
	
	function getAdmin()
	{
		$db	= & JFactory::getDBO(); 
		$db->setQuery( "SELECT email,name FROM `#__users` WHERE `gid` = 25 ORDER BY ID LIMIT 1" );
		$admin = $db->loadObject();
		return $admin;
	}
	
}

?>
Return current item: Chalange