function OAuthStoreSQL::__construct in Lingotek Translation 7.4
Same name and namespace in other branches
- 7.7 lib/oauth-php/library/store/OAuthStoreSQL.php \OAuthStoreSQL::__construct()
- 7.2 lib/oauth-php/library/store/OAuthStoreSQL.php \OAuthStoreSQL::__construct()
- 7.3 lib/oauth-php/library/store/OAuthStoreSQL.php \OAuthStoreSQL::__construct()
- 7.5 lib/oauth-php/library/store/OAuthStoreSQL.php \OAuthStoreSQL::__construct()
- 7.6 lib/oauth-php/library/store/OAuthStoreSQL.php \OAuthStoreSQL::__construct()
* Construct the OAuthStoreMySQL. * In the options you have to supply either: * - server, username, password and database (for a mysql_connect) * - conn (for the connection to be used) * *
Parameters
array options:
1 call to OAuthStoreSQL::__construct()
- OAuthStoreAnymeta::__construct in lib/
oauth-php/ library/ store/ OAuthStoreAnyMeta.php - * Construct the OAuthStoreAnymeta * *
3 methods override OAuthStoreSQL::__construct()
- OAuthStoreAnymeta::__construct in lib/
oauth-php/ library/ store/ OAuthStoreAnyMeta.php - * Construct the OAuthStoreAnymeta * *
- OAuthStoreMySQLi::__construct in lib/
oauth-php/ library/ store/ OAuthStoreMySQLi.php - * Construct the OAuthStoreMySQLi. * In the options you have to supply either: * - server, username, password and database (for a mysqli_connect) * - conn (for the connection to be used) * *
- OAuthStorePDO::__construct in lib/
oauth-php/ library/ store/ OAuthStorePDO.php - * Construct the OAuthStorePDO. * In the options you have to supply either: * - dsn, username, password and database (for a new PDO connection) * - conn (for the connection to be used) * *
File
- lib/
oauth-php/ library/ store/ OAuthStoreSQL.php, line 62
Class
Code
function __construct($options = array()) {
if (isset($options['conn'])) {
$this->conn = $options['conn'];
}
else {
if (isset($options['server'])) {
$server = $options['server'];
$username = $options['username'];
if (isset($options['password'])) {
$this->conn = mysql_connect($server, $username, $options['password']);
}
else {
$this->conn = mysql_connect($server, $username);
}
}
else {
// Try the default mysql connect
$this->conn = mysql_connect();
}
if ($this->conn === false) {
throw new OAuthException2('Could not connect to MySQL database: ' . mysql_error());
}
if (isset($options['database'])) {
if (!mysql_select_db($options['database'], $this->conn)) {
$this
->sql_errcheck();
}
}
$this
->query('set character set utf8');
}
}