function OAuthStoreMySQLi::__construct in Lingotek Translation 7.4
Same name and namespace in other branches
- 7.7 lib/oauth-php/library/store/OAuthStoreMySQLi.php \OAuthStoreMySQLi::__construct()
- 7.2 lib/oauth-php/library/store/OAuthStoreMySQLi.php \OAuthStoreMySQLi::__construct()
- 7.3 lib/oauth-php/library/store/OAuthStoreMySQLi.php \OAuthStoreMySQLi::__construct()
- 7.5 lib/oauth-php/library/store/OAuthStoreMySQLi.php \OAuthStoreMySQLi::__construct()
- 7.6 lib/oauth-php/library/store/OAuthStoreMySQLi.php \OAuthStoreMySQLi::__construct()
* 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) * *
Parameters
array options:
Overrides OAuthStoreSQL::__construct
File
- lib/
oauth-php/ library/ store/ OAuthStoreMySQLi.php, line 65
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 = $GLOBALS["___mysqli_ston"] = mysqli_connect($server, $username, $options['password']);
}
else {
$this->conn = $GLOBALS["___mysqli_ston"] = mysqli_connect($server, $username);
}
}
else {
// Try the default mysql connect
$this->conn = $GLOBALS["___mysqli_ston"] = mysqli_connect();
}
if ($this->conn === false) {
throw new OAuthException2('Could not connect to MySQL database: ' . (is_object($GLOBALS["___mysqli_ston"]) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false)));
}
if (isset($options['database'])) {
/* TODO: security. mysqli_ doesn't seem to have an escape identifier function.
$escapeddb = mysqli_real_escape_string($options['database']);
if (!((bool)mysqli_query( $this->conn, "USE `$escapeddb`" )))
{
$this->sql_errcheck();
}*/
}
$this
->query('set character set utf8');
}
}