/** * Database object constructor * * @param array $options List of options used to configure the connection * */ public function __construct($options) { $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'] : ''; // Finalize initialization parent::__construct($options); }
/** * Constructor. * * @param array $options List of options used to configure the connection * */ public function __construct($options) { // Get some basic values from the options. $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'] : ''; $options['select'] = isset($options['select']) ? (bool) $options['select'] : true; // Finalize initialisation parent::__construct($options); }
/** * Constructor. * * @param array $options List of options used to configure the connection * * @since 1.0 */ public function __construct($options) { // Get some basic values from the options. $options['driver'] = isset($options['driver']) ? $options['driver'] : 'odbc'; $options['dsn'] = isset($options['dsn']) ? $options['dsn'] : ''; $options['host'] = isset($options['host']) ? $options['host'] : 'localhost'; $options['database'] = isset($options['database']) ? $options['database'] : ''; $options['user'] = isset($options['user']) ? $options['user'] : ''; $options['password'] = isset($options['password']) ? $options['password'] : ''; $options['driverOptions'] = isset($options['driverOptions']) ? $options['driverOptions'] : array(); // Finalize initialisation parent::__construct($options); }
/** * Constructor. * * @param array $options List of options used to configure the connection * */ public function __construct($options) { // Get the default UTF8MB4 option $defaultAllowUtf8Mb4 = null; if (defined('ANGIE_ALLOW_UTF8MB4_DEFAULT')) { $defaultAllowUtf8Mb4 = ANGIE_ALLOW_UTF8MB4_DEFAULT; } // Get some basic values from the options. $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'] : ''; $options['select'] = isset($options['select']) ? (bool) $options['select'] : true; $options['port'] = isset($options['port']) ? (int) $options['port'] : null; $options['socket'] = isset($options['socket']) ? $options['socket'] : null; $options['utf8mb4'] = isset($options['utf8mb4']) ? $options['utf8mb4'] : $defaultAllowUtf8Mb4; // Figure out if a port is included in the host name if (empty($options['port'])) { // Unlike mysql_connect(), mysqli_connect() takes the port and socket // as separate arguments. Therefore, we have to extract them from the // host string. $options['port'] = null; $options['socket'] = null; $targetSlot = substr(strstr($options['host'], ":"), 1); if (!empty($targetSlot)) { // Get the port number or socket name if (is_numeric($targetSlot)) { $options['port'] = $targetSlot; } else { $options['socket'] = $targetSlot; } // Extract the host name only $host = substr($options['host'], 0, strlen($options['host']) - (strlen($targetSlot) + 1)); // This will take care of the following notation: ":3306" if ($host == '') { $options['host'] = 'localhost'; } } } // Finalize initialisation. parent::__construct($options); }