<?php
/*
 * ARI Framework Lite
 *
 * @package		ARI Framework Lite
 * @version		1.0.0
 * @author		ARI Soft
 * @copyright	Copyright (c) 2009 www.ari-soft.com. All rights reserved
 * @license		GNU/GPL (http://www.gnu.org/copyleft/gpl.html)
 * 
 */

(defined('_JEXEC') && defined('ARI_FRAMEWORK_LOADED')) or die;

require_once dirname(__FILE__) . '/ADODBLite/adodb.inc.php';

class AriADODBLite
{
	function createPConnection($dbHost, $dbUser, $dbPass, $dbName, $modules = null, $dbType = 'mysql')
	{
		$db = ADONewConnection($dbType, $modules);
		$res = $db->PConnect($dbHost, $dbUser, $dbPass, $dbName);
		
		return $res ? $db : null;
	}

	function createConnection($dbHost, $dbUser, $dbPass, $dbName, $modules = null, $dbType = 'mysql')
	{
		$db = ADONewConnection($dbType, $modules);
		$res = $db->Connect($dbHost, $dbUser, $dbPass, $dbName);
		
		return $res ? $db : null;
	}

	function createNConnect($dbHost, $dbUser, $dbPass, $dbName, $modules = null, $dbType = 'mysql')
	{
		$db = ADONewConnection($dbType, $modules);
		$res = $db->NConnect($dbHost, $dbUser, $dbPass, $dbName);
		
		return $res ? $db : null;
	}
	
	function isAllowedDbType($dbType)
	{
		$allowedDbTypes = array(
			'fbsql', 
			'gladius', 
			'maxdb', 
			'msql', 
			'mssql', 
			'mssqlpro', 
			'mysql', 
			'mysqli', 
			'mysqlt', 
			'odbc',
			'postgres',
			'postgres64',
			'postgres7',
			'postgres8',
			'sqlite',
			'sqlitepro',
			'sybase',
			'sybase_ace');
		
		return (!empty($dbType) && in_array($dbType, $allowedDbTypes));
	}
}