本文整理汇总了PHP中MySQLi::init方法的典型用法代码示例。如果您正苦于以下问题:PHP MySQLi::init方法的具体用法?PHP MySQLi::init怎么用?PHP MySQLi::init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MySQLi
的用法示例。
在下文中一共展示了MySQLi::init方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: empty
function __construct($config)
{
mysqli_report(MYSQLI_REPORT_ERROR);
$this->cfg = array_merge($this->cfg, $config);
if (preg_match('#^(.*)?:(\\d+)?$#D', $this->cfg['host'], $match)) {
$this->cfg['host'] = empty($match[1]) ? null : $match[1];
$this->cfg['port'] = empty($match[2]) ? null : $match[2];
}
if (!$this->cfg['socket']) {
$this->cfg['socket'] = null;
}
if (!is_int($this->cfg['flags'])) {
$this->cfg['flags'] = null;
}
if (!is_array($this->cfg['options'])) {
$this->cfg['options'] = array();
}
parent::init();
foreach ($this->cfg['options'] as $option => $value) {
if (!parent::options($option, $value)) {
throw new Exception($this->error, $this->errno);
}
}
$ssl =& $this->cfg['ssl'];
if ($ssl['key'] || $ssl['cert'] || $ssl['ca'] || $ssl['capath'] || $ssl['cipher']) {
# bugs.php.net/bug.php?id=51026 & bugs.php.net/bug.php?id=37620
if (version_compare(phpversion(), '5.3.0', '>=') && version_compare(phpversion(), '5.3.3', '<')) {
throw new Exception('MySQLi SSL not available due to PHP bug 51026');
}
parent::ssl_set($ssl['key'], $ssl['cert'], $ssl['ca'], $ssl['capath'], $ssl['cipher']);
}
$this->connect();
}
示例2: init
private function init()
{
$handle = new MySQLi();
$handle->init();
$handle->options(MYSQLI_OPT_CONNECT_TIMEOUT, 5);
if (@$handle->real_connect(_DBMS_HOST, _DBMS_LOGIN, _DBMS_PASS, _DBMS_DB) === FALSE) {
throw new DatabaseException($handle->connect_error);
}
if (!$handle->select_db(_DBMS_DB)) {
throw new DatabaseException('Can\'t connect to Database !');
}
return $handle;
}
示例3:
function __construct()
{
parent::init();
}