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


PHP resource::errorCode方法代碼示例

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


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

示例1: _lastErrNo

 /**
  * Get the last error number
  */
 protected function _lastErrNo()
 {
     $error = '';
     if ($this->connection) {
         $error = $this->connection->errorCode();
     }
     return $error;
 }
開發者ID:mvnp,項目名稱:Simple-MVC-Framework,代碼行數:11,代碼來源:Database.class.php

示例2: query

 /**
  * 直接查詢Sql
  *
  * @param String $SQL
  * @return Mix
  */
 function query($sql)
 {
     if (!$this->conn) {
         $this->connect();
     }
     if (strtolower(substr(ltrim($sql), 0, 5)) == 'alter') {
         $queryparts = preg_split("/[\\s]+/", $sql, 4, PREG_SPLIT_NO_EMPTY);
         $tablename = $queryparts[2];
         $alterdefs = $queryparts[3];
         $result = $this->alterTable($tablename, $alterdefs);
     } else {
         if ($this->type == "SQLite2") {
             $result = sqlite_query($sql, $this->conn);
         } else {
             $result = $this->conn->query($sql);
         }
     }
     if (!$result) {
         if ($this->type == "SQLite2") {
             $this->lasterr = sqlite_last_error($this->conn);
             $this->lasterrcode = sqlite_error_string($this->lasterr);
         } elseif ($this->type == "SQLite3") {
             $this->lasterr = $this->conn->lastErrorCode();
             $this->lasterrcode = $this->conn->lastErrorMsg();
         } elseif ($this->type == 'PDO') {
             $this->lasterr = $this->conn->errorCode();
             $this->lasterrcode = implode(',', $this->conn->errorInfo());
         }
         if ($this->_transflag) {
             $this->_transErrors[]['sql'] = $sql;
             $this->_transErrors[]['errcode'] = $this->lasterrcode;
             $this->_transErrors[]['err'] = $this->lasterr;
         } else {
             exit('SQL:' . $sql . ' ERROR_INFO:' . $this->lasterrcode . ',' . $this->lasterr);
             return false;
         }
     } else {
         $this->query_num++;
         $this->lastResult = $result;
         return $result;
     }
 }
開發者ID:jorkin,項目名稱:meiupic,代碼行數:48,代碼來源:sqlite.php

示例3: execute

 /**
  * 執行一個查詢,返回一個 resource 或者 boolean 值
  *
  * @param string $sql
  * @param array $inputarr
  * @param boolean $throw 指示查詢出錯時是否拋出異常
  * @return resource |boolean
  */
 function execute($sql, $inputarr = null, $throw = true)
 {
     if (substr($sql, 0, 11) == "INSERT INTO") {
         // 刪除SQL中的指定的表,SQLITE不支持在插入中語句有表名在前麵
         $len1 = strpos($sql, '(');
         $len2 = strpos($sql, ')');
         $len3 = strpos($sql, 'VALUES');
         $temp = array();
         if ($len2 < $len3) {
             $temp[] = substr($sql, 0, $len1);
             $temp[] = substr($sql, $len1, $len2 - $len1);
             $temp[] = substr($sql, $len2);
             $temp[1] = eregi_replace("[a-z_0-9]+\\.", "", $temp[1]);
             $sql = implode($temp);
         }
     }
     if (is_array($inputarr)) {
         $sql = $this->_prepareSql($sql, $inputarr);
     }
     if ($this->enableLog) {
         $this->log[] = $sql;
         log_message("sql:\n{$sql}", 'debug');
     }
     $result = $this->conn->query($sql);
     if ($result !== false) {
         $this->lasterr = null;
         $this->lasterrcode = null;
         return $result;
     }
     $this->lasterrcode = $this->conn->errorCode();
     $this->lasterr = $this->conn->errorInfo();
     if (!$throw) {
         return false;
     }
     FLEA::loadClass('FLEA_Db_Exception_SqlQuery');
     __THROW(new FLEA_Db_Exception_SqlQuery($sql, $this->lasterr[2], $this->lasterrcode));
     return false;
 }
開發者ID:BGCX261,項目名稱:zlskytakeorder-svn-to-git,代碼行數:46,代碼來源:Sqlitepdo.php

示例4: errno

 /**
  * Returns the numerical value of the error message from previous
  * MySQL operation
  *
  * @return int Returns the error number from the last MySQL function
  * , or 0 (zero) if no error occurred.
  * @deprecated since version 2.6.0 - alpha 3. Switch to doctrine connector.
  */
 public function errno()
 {
     $this->deprecated();
     return $this->conn->errorCode();
 }
開發者ID:redmexico,項目名稱:XoopsCore,代碼行數:13,代碼來源:mysqldatabase.php


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