本文整理汇总了PHP中mysqli::ssl_set方法的典型用法代码示例。如果您正苦于以下问题:PHP mysqli::ssl_set方法的具体用法?PHP mysqli::ssl_set怎么用?PHP mysqli::ssl_set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mysqli
的用法示例。
在下文中一共展示了mysqli::ssl_set方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: connect
/**
* Connect to database
* @return bool
*/
public function connect($host, $user, $pass, $port = 3306, $options = array())
{
$client_flags = defined('MYSQL_CLIENT_FLAGS') ? MYSQL_CLIENT_FLAGS : 0;
$this->dbh = mysqli_init();
$socket = null;
$port_or_socket = strstr($host, ':');
if (!empty($port_or_socket)) {
$host = substr($host, 0, strpos($host, ':'));
$port_or_socket = substr($port_or_socket, 1);
if (0 !== strpos($port_or_socket, '/')) {
$port = intval($port_or_socket);
$maybe_socket = strstr($port_or_socket, ':');
if (!empty($maybe_socket)) {
$socket = substr($maybe_socket, 1);
}
} else {
$socket = $port_or_socket;
$port = null;
}
}
if (WP_DEBUG) {
$this->dbh->real_connect($host, $user, $pass, null, $port, $socket, $client_flags);
} else {
@$this->dbh->real_connect($host, $user, $pass, null, $port, $socket, $client_flags);
}
if (!empty($options['key']) && !empty($options['cert']) && !empty($options['ca'])) {
$this->dbh->ssl_set($options['key'], $options['cert'], $options['ca'], $options['ca_path'], $options['cipher']);
}
return !mysqli_connect_error();
}
示例2: connect
/**
* Establishes a connection to the defined mysql-server.
*
* @return void
*/
public function connect()
{
if ($this->connected === TRUE) {
return;
}
if ($this->configuration['db']['driver'] != 'mysql') {
$this->logger->error('Cannot connect to a non-mysql database connection!');
return;
}
$host = $this->readonly === TRUE ? $this->ro_host : $this->rw_host;
if (isset($this->ssl_key, $this->ssl_cert, $this->ca_cert)) {
$this->mysqli->ssl_set($this->ssl_key, $this->ssl_cert, $this->ca_cert, $this->ca_path, $this->cipher);
}
$this->mysqli->connect($host, $this->user, $this->pwd, $this->db, $this->port, $this->socket);
if ($this->mysqli->errno === 0) {
$this->mysqli->set_charset('utf8');
$this->connected = TRUE;
}
}
示例3: _initConnection
private function _initConnection()
{
// return new mysqli($this->host, $this->login, $this->password, $this->database);
$mysqli = new mysqli();
if (isset($this->sslKeyFile) && isset($this->sslCertFile) && isset($this->sslCaFile)) {
$mysqli->ssl_set($this->sslKeyFile, $this->sslCertFile, $this->sslCaFile, null, null);
}
if (!$mysqli->real_connect($this->host, $this->login, $this->password, $this->database)) {
$this->errno = $mysqli->connect_errno;
$this->error = $mysqli->connect_error;
}
return $mysqli;
}
示例4: get
public function get()
{
$mysql = $this->internal_mysql;
if (!$mysql instanceof MySQLi) {
if (!$this->port) {
$this->port = ini_get('mysqli.default_port');
}
$this->current_db = $this->dbName;
$mysql = new mysqli();
$connect_flags = 0;
if ($this->ssl['key']) {
$mysql->ssl_set($this->ssl['key'], $this->ssl['cert'], $this->ssl['ca_cert'], $this->ssl['ca_path'], $this->ssl['cipher']);
$connect_flags |= MYSQLI_CLIENT_SSL;
}
foreach ($this->connect_options as $key => $value) {
$mysql->options($key, $value);
}
// suppress warnings, since we will check connect_error anyway
@$mysql->real_connect($this->host, $this->user, $this->password, $this->dbName, $this->port, null, $connect_flags);
if ($mysql->connect_error) {
$this->nonSQLError('Unable to connect to MySQL server! Error: ' . $mysql->connect_error);
}
$mysql->set_charset($this->encoding);
$this->internal_mysql = $mysql;
$this->server_info = $mysql->server_info;
}
return $mysql;
}