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


PHP PDO::setCharset方法代碼示例

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


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

示例1: init

 /**
  * 初始化DB句柄
  * 
  * @return void
  * @throws WindDbException
  */
 public function init()
 {
     try {
         if ($this->_dbHandle !== null) {
             return;
         }
         $driverName = $this->getDriverName();
         $dbHandleClass = "WIND:db." . $driverName . ".Wind" . ucfirst($driverName) . "PdoAdapter";
         $dbHandleClass = Wind::import($dbHandleClass);
         $this->_dbHandle = new $dbHandleClass($this->_dsn, $this->_user, $this->_pwd, (array) $this->_attributes);
         $this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
         $this->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true);
         $this->_dbHandle->setCharset($this->_charset);
     } catch (PDOException $e) {
         $this->close();
         throw new WindDbException('[db.WindConnection.init] ' . $e->getMessage());
     }
 }
開發者ID:ccq18,項目名稱:EduSoho,代碼行數:24,代碼來源:WindConnection.php

示例2: init

 /**
  * 初始化DB句柄
  * 
  * @return void
  * @throws WindDbException
  */
 public function init()
 {
     try {
         if ($this->_dbHandle !== null) {
             return;
         }
         $driverName = $this->getDriverName();
         $dbHandleClass = "WIND:db." . $driverName . ".Wind" . ucfirst($driverName) . "PdoAdapter";
         $dbHandleClass = Wind::import($dbHandleClass);
         $this->_dbHandle = new $dbHandleClass($this->_dsn, $this->_user, $this->_pwd, (array) $this->_attributes);
         $this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
         $this->_dbHandle->setCharset($this->_charset);
         if (WIND_DEBUG & 2) {
             Wind::getApp()->getComponent('windLogger')->info("[db.WindConnection.init] Initialize db connection success. \r\n\tDSN:" . $this->_dsn . "\r\n\tUser:" . $this->_user . "\r\n\tCharset:" . $this->_charset . "\r\n\tTablePrefix:" . $this->_tablePrefix . "\r\n\tDriverName:" . $this->_driverName, 'db');
         }
     } catch (PDOException $e) {
         $this->close();
         throw new WindDbException($e->getMessage());
     }
 }
開發者ID:jellycheng,項目名稱:windframework,代碼行數:26,代碼來源:WindConnection.php


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