function OAuthStorePostgreSQL::__construct in Lingotek Translation 7.3
Same name and namespace in other branches
- 7.7 lib/oauth-php/library/store/OAuthStorePostgreSQL.php \OAuthStorePostgreSQL::__construct()
- 7.2 lib/oauth-php/library/store/OAuthStorePostgreSQL.php \OAuthStorePostgreSQL::__construct()
- 7.4 lib/oauth-php/library/store/OAuthStorePostgreSQL.php \OAuthStorePostgreSQL::__construct()
- 7.5 lib/oauth-php/library/store/OAuthStorePostgreSQL.php \OAuthStorePostgreSQL::__construct()
- 7.6 lib/oauth-php/library/store/OAuthStorePostgreSQL.php \OAuthStorePostgreSQL::__construct()
Construct the OAuthStorePostgrSQL. In the options you have to supply either:
- server, username, password and database (for a pg_connect)
- connectionString (for a pg_connect)
- conn (for the connection to be used)
Parameters
array options:
File
- lib/
oauth-php/ library/ store/ OAuthStorePostgreSQL.php, line 72
Class
Code
function __construct($options = array()) {
if (isset($options['conn'])) {
$this->conn = $options['conn'];
}
else {
if (isset($options['server'])) {
$host = $options['server'];
$user = $options['username'];
$dbname = $options['database'];
$connectionString = sprintf('host=%s dbname=%s user=%s', $host, $dbname, $user);
if (isset($options['password'])) {
$connectionString .= ' password=' . $options['password'];
}
$this->conn = pg_connect($connectionString);
}
elseif (isset($options['connectionString'])) {
$this->conn = pg_connect($options['connectionString']);
}
else {
// Try the default pg connect
$this->conn = pg_connect();
}
if ($this->conn === false) {
throw new OAuthException2('Could not connect to PostgresSQL database');
}
}
}