/** * Initialize the storage container * * @param array Array with the storage configuration * @return bool true on success, false on failure. * * @access public */ function init($storageConf) { parent::init($storageConf); if (!MDB::isConnection($this->dbc) && !is_null($this->dsn)) { $this->options['optimize'] = 'portability'; if ($this->function == 'singleton') { $dbc =& MDB::singleton($this->dsn, $this->options); } else { $dbc =& MDB::connect($this->dsn, $this->options); } if (PEAR::isError($dbc)) { $this->stack->push(LIVEUSER_ERROR_INIT_ERROR, 'error', array('container' => 'could not connect: ' . $dbc->getMessage(), 'debug' => $dbc->getUserInfo())); return false; } $this->dbc =& $dbc; } if (!MDB::isConnection($this->dbc)) { $this->stack->push(LIVEUSER_ERROR_INIT_ERROR, 'error', array('container' => 'storage layer configuration missing')); return false; } return true; }
/** * Initialize the storage container * * @param array Array with the storage configuration * @return bool true on success, false on failure. * * @access public */ function init(&$storageConf) { parent::init($storageConf); if (!is_a($this->dbc, 'db_common') && !is_null($this->dsn)) { $this->options['portability'] = DB_PORTABILITY_ALL; $dbc =& DB::connect($this->dsn, $this->options); if (PEAR::isError($dbc)) { $this->stack->push(LIVEUSER_ERROR_INIT_ERROR, 'error', array('container' => 'could not connect: ' . $dbc->getMessage(), 'debug' => $dbc->getUserInfo())); return false; } $this->dbc =& $dbc; } if (!is_a($this->dbc, 'db_common')) { $this->stack->push(LIVEUSER_ERROR_INIT_ERROR, 'error', array('container' => 'storage layer configuration missing')); return false; } return true; }
/** * * * * @param array &$storageConf Array with the storage configuration * @return boolean true on success, false on failure. * * @access public */ function init(&$storageConf) { if (!parent::init($storageConf)) { return false; } if (array_key_exists('connection', $storageConf) && DB::isConnection($storageConf['connection'])) { $this->dbc =& $storageConf['connection']; } elseif (array_key_exists('dsn', $storageConf)) { $this->dsn = $storageConf['dsn']; $options = null; if (array_key_exists('options', $storageConf)) { $options = $storageConf['options']; } $options['portability'] = DB_PORTABILITY_ALL; $this->dbc =& DB::connect($storageConf['dsn'], $options); if (PEAR::isError($this->dbc)) { $this->_stack->push(LIVEUSER_ERROR_INIT_ERROR, 'error', array('container' => 'could not connect: ' . $this->dbc->getMessage())); return false; } } return true; }
/** * Initialize the storage container * * @param array Array with the storage configuration * @return bool true on success, false on failure. * * @access public */ function init(&$storageConf) { parent::init($storageConf); if (!is_a($this->dbc, 'pdo') && !is_null($this->dsn)) { $login = $password = $extra = null; if (!empty($this->options)) { if (array_key_exists('username', $this->options)) { $login = $this->options['username']; } if (array_key_exists('password', $this->options)) { $password = $this->options['password']; } if (array_key_exists('attr', $this->options)) { $extra = $this->options['attr']; } } try { $dbc = new PDO($this->dsn, $login, $password, $extra); } catch (PDOException $e) { $this->stack->push(LIVEUSER_ERROR_INIT_ERROR, 'error', array('container' => 'could not connect: ' . $e->getMessage(), 'debug' => $e->getTrace())); return false; } $this->dbc = $dbc; } if (!is_a($this->dbc, 'pdo')) { $this->stack->push(LIVEUSER_ERROR_INIT_ERROR, 'error', array('container' => 'storage layer configuration missing')); return false; } return true; }
/** * * * * @param array &$storageConf Array with the storage configuration * @return boolean true on success, false on failure. * * @access public */ function init($storageConf) { if (!parent::init($storageConf)) { return false; } if (array_key_exists('connection', $storageConf) && MDB::isConnection($storageConf['connection'])) { $this->dbc =& $storageConf['connection']; } elseif (array_key_exists('dsn', $storageConf)) { $this->dsn = $storageConf['dsn']; $function = null; if (array_key_exists('function', $storageConf)) { $function = $storageConf['function']; } $options = null; if (array_key_exists('options', $storageConf)) { $options = $storageConf['options']; } $options['optimize'] = 'portability'; if ($function == 'singleton') { $this->dbc =& MDB::singleton($storageConf['dsn'], $options); } else { $this->dbc =& MDB::connect($storageConf['dsn'], $options); } if (PEAR::isError($this->dbc)) { $this->_stack->push(LIVEUSER_ERROR_INIT_ERROR, 'error', array('container' => 'could not connect: ' . $this->dbc->getMessage())); return false; } } return true; }