當前位置: 首頁>>代碼示例>>PHP>>正文


PHP wpdb::set_charset方法代碼示例

本文整理匯總了PHP中wpdb::set_charset方法的典型用法代碼示例。如果您正苦於以下問題:PHP wpdb::set_charset方法的具體用法?PHP wpdb::set_charset怎麽用?PHP wpdb::set_charset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在wpdb的用法示例。


在下文中一共展示了wpdb::set_charset方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: wpdb

 function connect_s9ydb()
 {
     $s9ydb = new wpdb(get_option('s9yuser'), get_option('s9ypass'), get_option('s9yname'), get_option('s9yhost'));
     $s9ydb->set_charset($s9ydb->dbh, get_option('s9ycharset'));
     set_magic_quotes_runtime(0);
     return $s9ydb;
 }
開發者ID:jimjag,項目名稱:s9y-to-wp,代碼行數:7,代碼來源:serendipity.php

示例2: connectDatabase

 /**
  *	connectDatabase()
  *
  *	Initializes a connection to the mysql database.
  *	REQUIRES: databaseSettings portion of state to be set.
  *
  *	@return		boolean		True on success; else false. Success testing is very loose.
  */
 function connectDatabase()
 {
     $this->_before(__FUNCTION__);
     global $wpdb;
     $wpdb = new wpdb($this->_state['databaseSettings']['username'], $this->_state['databaseSettings']['password'], $this->_state['databaseSettings']['database'], $this->_state['databaseSettings']['server']);
     // See if we have a specified character set and collation to use from the source site.
     $charset = null;
     $collate = null;
     if (isset($this->_state['dat']['db_charset'])) {
         $charset = $this->_state['dat']['db_charset'];
     }
     if (isset($this->_state['dat']['db_collate'])) {
         $collate = $this->_state['dat']['db_collate'];
     }
     if (null !== $charset || null !== $collate) {
         pb_backupbuddy::status('details', 'Setting charset to `' . $charset . '` and collate to `' . $collate . '` based on source site.');
         $wpdb->set_charset($wpdb->dbh, $charset, $collate);
     } else {
         pb_backupbuddy::status('details', 'Charset nor collate are in DAT file. Using defaults for database connection.');
         pb_backupbuddy::status('details', 'Charset in wpdb: ' . $wpdb->charset);
     }
     // Warn if mysql versions are incompatible; eg importing a mysql < 5.1 version into a server running 5.1+.
     global $wpdb;
     if (isset($this->_state['dat']['db_version'])) {
         $incomingVersion = $this->_state['dat']['db_version'];
     }
     $thisVersion = $wpdb->db_version();
     pb_backupbuddy::status('details', 'Incoming mysql version: `' . $incomingVersion . '`. This server\'s mysql version: `' . $thisVersion . '`.');
     if (version_compare($incomingVersion, '5.1.0', '<') && version_compare($thisVersion, '5.1.0', '>=')) {
         pb_backupbuddy::status('warning', 'Error #7001: This server\'s mysql version, `' . $thisVersion . '` may have SQL query incompatibilities with the backup mysql version `' . $incomingVersion . '`. This may result in #9010 errors due to syntax of TYPE= changing to ENGINE=. If none occur you may ignore this error.');
     }
     return true;
 }
開發者ID:elephantcode,項目名稱:elephantcode,代碼行數:41,代碼來源:restore.php

示例3: connectDatabase

 /**
  *	connectDatabase()
  *
  *	Initializes a connection to the mysql database.
  *	REQUIRES: databaseSettings portion of state to be set.
  *
  *	@return		boolean		True on success; else false. Success testing is very loose.
  */
 function connectDatabase()
 {
     $this->_before(__FUNCTION__);
     global $wpdb;
     $wpdb = new wpdb($this->_state['databaseSettings']['username'], $this->_state['databaseSettings']['password'], $this->_state['databaseSettings']['database'], $this->_state['databaseSettings']['server']);
     // See if we have a specified character set and collation to use from the source site.
     $charset = null;
     $collate = null;
     if (isset($this->_state['dat']['db_charset'])) {
         $charset = $this->_state['dat']['db_charset'];
     }
     if (isset($this->_state['dat']['db_collate'])) {
         $collate = $this->_state['dat']['db_collate'];
     }
     if (null !== $charset || null !== $collate) {
         pb_backupbuddy::status('details', 'Setting charset to `' . $charset . '` and collate to `' . $collate . '` based on source site.');
         $wpdb->set_charset($wpdb->dbh, $charset, $collate);
     } else {
         pb_backupbuddy::status('details', 'Charset nor collate are in DAT file. Using defaults for database connection.');
         pb_backupbuddy::status('details', 'Charset in wpdb: ' . $wpdb->charset);
     }
     return true;
 }
開發者ID:ryankrieg,項目名稱:wordpress-base,代碼行數:31,代碼來源:restore.php


注:本文中的wpdb::set_charset方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。