function &getServiceInstance($name, $servicedir = NULL) {
global $dbhost, $dbuser, $dbpass, $dbname, $dbport, $dbpersist, $dbtype;
static $instances = array();
static $db;
if (!isset($db)) {
function &getServiceInstance($name, $servicedir = NULL) {
global $dbhost, $dbuser, $dbpass, $dbname, $dbport, $dbpersist, $dbtype;
static $instances = array();
static $db;
if (!isset($db)) {