本文整理汇总了PHP中false::set_charset方法的典型用法代码示例。如果您正苦于以下问题:PHP false::set_charset方法的具体用法?PHP false::set_charset怎么用?PHP false::set_charset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类false
的用法示例。
在下文中一共展示了false::set_charset方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setCharset
/**
* Set character set
*
* @return bool true on success, false otherwise
*/
private function setCharset()
{
$charset = strtolower($this->_charset);
if (!in_array($charset, array('utf-8', 'utf8', 'utf8mb4'))) {
return true;
}
if ($charset === 'utf-8') {
// before GL-2.1.2
$charset = 'utf8';
} elseif ($charset === 'utf8mb4') {
// since GL-2.1.2
if ($this->_mysql_version < 50503) {
$charset = 'utf8';
}
}
$this->_charset = $charset;
$retval = false;
if (method_exists($this->_db, 'set_charset')) {
$retval = @$this->_db->set_charset($charset);
}
if (!$retval) {
$retval = @$this->_db->query("SET NAMES '{$this->_charset}'");
}
return $retval;
}
示例2: _connect
/**
* Connects to the MySQL database server
*
* This function connects to the MySQL server and returns the connection object
*
* @return object Returns connection object
* @access private
*/
private function _connect()
{
if ($this->_verbose) {
$this->_errorlog("DEBUG: mysqli - inside database->_connect");
}
// Connect to MySQL server
$this->_db = @new mysqli($this->_host, $this->_user, $this->_pass);
if ($this->_db->connect_errno) {
die('Connect Error: ' . $this->_db->connect_errno);
}
$this->_mysql_version = $this->_db->server_version;
// Set the database
$this->_db->select_db($this->_name) or die('error selecting database');
if (!$this->_db) {
if ($this->_verbose) {
$this->_errorlog("DEUBG: mysqli - error in database->_connect");
}
// damn, got an error.
$this->dbError();
}
if ($this->_charset === 'utf-8') {
$result = false;
if (method_exists($this->_db, 'set_charset')) {
$result = $this->_db->set_charset('utf8');
}
if (!$result) {
@$this->_db->query("SET NAMES 'utf8'");
}
}
if ($this->_mysql_version >= 50700) {
$result = $this->_db->query("SELECT @@sql_mode");
$modeData = $this->dbFetchArray($result);
$updatedMode = '';
$first = 0;
$found = 0;
if (isset($modeData["@@sql_mode"])) {
$modeArray = explode(",", $modeData["@@sql_mode"]);
foreach ($modeArray as $setting) {
if ($setting == 'ONLY_FULL_GROUP_BY') {
$found = 1;
continue;
}
if ($first != 0) {
$updatedMode .= ',';
}
$updatedMode .= $setting;
$first++;
}
if ($found == 1) {
@$this->_db->query("SET sql_mode = '" . $updatedMode . "'");
}
}
}
if ($this->_verbose) {
$this->_errorlog("DEBUG: mysqli - leaving database->_connect");
}
}
示例3: _connect
/**
* Connects to the MySQL database server
* This function connects to the MySQL server and returns the connection object
*
* @return object Returns connection object
* @access private
*/
private function _connect()
{
global $_TABLES, $use_innodb;
if ($this->_verbose) {
$this->_errorlog("\n*** Inside database->_connect ***");
}
// Connect to MySQL server
$this->_db = new mysqli($this->_host, $this->_user, $this->_pass);
if (!$this->_db instanceof mysqli) {
die('Cannot connect to DB server');
}
$this->_mysql_version = $this->_db->server_version;
// Set the database
$this->_db->select_db($this->_name) || die('error selecting database');
if (!$this->_db) {
if ($this->_verbose) {
$this->_errorlog("\n*** Error in database->_connect ***");
}
// damn, got an error.
$this->dbError();
}
if ($this->_mysql_version >= 40100) {
if ($this->_charset === 'utf-8') {
$result = false;
if (method_exists($this->_db, 'set_charset')) {
$result = $this->_db->set_charset('utf8');
}
if (!$result) {
@$this->_db->query("SET NAMES 'utf8'");
}
}
}
// Checks if db engine is InnoDB. During the installation
// $_TABLES['vars'] is not yet created, so we use $use_innodb instead.
if (isset($use_innodb)) {
$this->_use_innodb = (bool) $use_innodb;
} else {
if ($this->dbTableExists('vars')) {
$result = $this->dbQuery("SELECT value FROM {$_TABLES['vars']} WHERE (name = 'database_engine')");
if ($result !== false && $this->dbNumRows($result) == 1) {
$A = $this->dbFetchArray($result, false);
$this->_use_innodb = strcasecmp($A['value'], 'InnoDB') === 0;
}
}
}
if ($this->_verbose) {
$this->_errorlog("\n***leaving database->_connect***");
}
}