3 function ServiceFactory(&$db, $serviceoverrules = array()) {
6 function &getServiceInstance($name, $servicedir = NULL) {
7 global $dbhost, $dbuser, $dbpass, $dbname, $dbport, $dbpersist, $dbtype;
8 static $instances = array();
11 require_once(dirname(__FILE__) .'/../includes/db/'. $dbtype .'.php');
13 $db->sql_connect($dbhost, $dbuser, $dbpass, $dbname, $dbport, $dbpersist);
14 if(!$db->db_connect_id) {
15 message_die(CRITICAL_ERROR, "Could not connect to the database", $db);
18 if (!isset($instances[$name])) {
19 if (isset($serviceoverrules[$name])) {
20 $name = $serviceoverrules[$name];
22 if (!class_exists($name)) {
23 if (!isset($servicedir)) {
24 $servicedir = dirname(__FILE__) .'/';
26 require_once($servicedir . strtolower($name) . '.php');
28 $instances[$name] = call_user_func(array($name, 'getInstance'), $db);
30 return $instances[$name];