/** * Database object constructor * @param array List of options used to configure the connection */ public function __construct($options) { $this->driverType = 'mysql'; // Init $this->nameQuote = '`'; $host = array_key_exists('host', $options) ? $options['host'] : 'localhost'; $port = array_key_exists('port', $options) ? $options['port'] : ''; $user = array_key_exists('user', $options) ? $options['user'] : ''; $password = array_key_exists('password', $options) ? $options['password'] : ''; $database = array_key_exists('database', $options) ? $options['database'] : ''; $prefix = array_key_exists('prefix', $options) ? $options['prefix'] : ''; $select = array_key_exists('select', $options) ? $options['select'] : true; if (!empty($port)) { $host .= ':' . $port; } // finalize initialization parent::__construct($options); // Open the connection $this->host = $host; $this->user = $user; $this->password = $password; $this->_database = $database; $this->selectDatabase = $select; if (!is_resource($this->connection) || is_null($this->connection)) { $this->open(); } }
/** * Database object constructor * @param array List of options used to configure the connection */ public function __construct( $options ) { // Init $this->nameQuote = '`'; $host = array_key_exists('host', $options) ? $options['host'] : 'localhost'; $port = array_key_exists('port', $options) ? $options['port'] : ''; $user = array_key_exists('user', $options) ? $options['user'] : ''; $password = array_key_exists('password',$options) ? $options['password'] : ''; $database = array_key_exists('database',$options) ? $options['database'] : ''; $prefix = array_key_exists('prefix', $options) ? $options['prefix'] : ''; $select = array_key_exists('select', $options) ? $options['select'] : true; if(!empty($port)) $host .= ':'.$port; // finalize initialization parent::__construct($options); // Open the connection $this->host = $host; $this->user = $user; $this->password = $password; $this->database = $database; $this->open(); }
/** * Database object constructor * @param array List of options used to configure the connection */ public function __construct( $options ) { // Init $this->nameQuote = '`'; $host = array_key_exists('host', $options) ? $options['host'] : 'localhost'; $port = array_key_exists('port', $options) ? $options['port'] : ''; $user = array_key_exists('user', $options) ? $options['user'] : ''; $password = array_key_exists('password',$options) ? $options['password'] : ''; $database = array_key_exists('database',$options) ? $options['database'] : ''; $prefix = array_key_exists('prefix', $options) ? $options['prefix'] : ''; $select = array_key_exists('select', $options) ? $options['select'] : true; // Figure out if a port is included in the host name if(empty($port)) { // Unlike mysql_connect(), mysqli_connect() takes the port and socket // as separate arguments. Therefore, we have to extract them from the // host string. $port = NULL; $socket = NULL; $targetSlot = substr( strstr( $host, ":" ), 1 ); if (!empty( $targetSlot )) { // Get the port number or socket name if (is_numeric( $targetSlot )) $port = $targetSlot; else $socket = $targetSlot; // Extract the host name only $host = substr( $host, 0, strlen( $host ) - (strlen( $targetSlot ) + 1) ); // This will take care of the following notation: ":3306" if($host == '') $host = 'localhost'; } } // finalize initialization parent::__construct($options); // Open the connection $this->host = $host; $this->user = $user; $this->password = $password; $this->port = $port; $this->socket = $socket; $this->database = $database; $this->open(); }
/** * Database object constructor * @param array List of options used to configure the connection */ public function __construct($options) { // Get best matching Akeeba Backup driver instance if (class_exists('JFactory')) { $this->dbo = JFactory::getDBO(); } else { $driver = AEPlatform::getInstance()->get_default_database_driver(false); $this->dbo = new $driver($options); } // Propagate errors $this->propagateFromObject($this->dbo); $this->nameQuote = '`'; parent::__construct($options); $this->database = $options['database']; }
/** * Constructor. * * @param array $options List of options used to configure the connection * * @since 11.1 */ public function __construct($options) { $this->driverType = 'mssql'; // Get some basic values from the options. $host = array_key_exists('host', $options) ? $options['host'] : 'localhost'; $port = array_key_exists('port', $options) ? $options['port'] : ''; $user = array_key_exists('user', $options) ? $options['user'] : ''; $password = array_key_exists('password', $options) ? $options['password'] : ''; $database = array_key_exists('database', $options) ? $options['database'] : ''; $prefix = array_key_exists('prefix', $options) ? $options['prefix'] : ''; $select = array_key_exists('select', $options) ? $options['select'] : true; // Build the connection configuration array. $this->connectionConfig = array('Database' => $database, 'uid' => $user, 'pwd' => $password, 'CharacterSet' => 'UTF-8', 'ReturnDatesAsStrings' => true); parent::__construct($options); $this->host = $host; $this->user = $user; $this->password = $password; $this->_database = $database; $this->selectDatabase = $select; if (!is_resource($this->connection)) { $this->open(); } }
/** * Database object constructor * * @param array $options List of options used to configure the connection * */ public function __construct($options) { $this->driverType = 'postgresql'; $options['host'] = isset($options['host']) ? $options['host'] : 'localhost'; $options['user'] = isset($options['user']) ? $options['user'] : ''; $options['password'] = isset($options['password']) ? $options['password'] : ''; $options['database'] = isset($options['database']) ? $options['database'] : ''; $host = array_key_exists('host', $options) ? $options['host'] : 'localhost'; $port = array_key_exists('port', $options) ? $options['port'] : ''; $user = array_key_exists('user', $options) ? $options['user'] : ''; $password = array_key_exists('password', $options) ? $options['password'] : ''; $database = array_key_exists('database', $options) ? $options['database'] : ''; $prefix = array_key_exists('prefix', $options) ? $options['prefix'] : ''; $select = array_key_exists('select', $options) ? $options['select'] : true; // Finalize initialization parent::__construct($options); if (!is_resource($this->connection) || is_null($this->connection)) { $this->open(); } }