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


PHP object::errorInfo方法代碼示例

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


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

示例1: drop

 /**
  * Drop a MySQL table
  *
  * @param string $sTable
  * @return bool
  */
 public function drop($sTable = '')
 {
     // if table name not pass
     if (!empty($sTable)) {
         // create count query
         $this->sSql = "DROP TABLE `{$sTable}`;";
         // pdo prepare statement
         $this->_oSTH = $this->prepare($this->sSql);
         try {
             if ($this->_oSTH->execute()) {
                 // close pdo
                 $this->_oSTH->closeCursor();
                 // return number of count
                 return true;
             } else {
                 self::error($this->_oSTH->errorInfo());
             }
         } catch (PDOException $e) {
             // get pdo error and pass on error method
             self::error($e->getMessage() . ': ' . __LINE__);
         }
     } else {
         self::error('Table name not found..');
     }
 }
開發者ID:kesumu,項目名稱:WebComponent,代碼行數:31,代碼來源:class.pdowrapper.php

示例2: query

 /**
  * 執行sql查詢
  *
  * @param string sql語句
  * @param array 參數數組
  * @param string 返回結果綁定到的對象
  * @param boolean 是否輸出調試語句
  * @return void
  */
 public function query($sql, $params = array(), $class = 'stdClass', $debug = FALSE)
 {
     // 預處理綁定語句
     try {
         $this->stmt = $this->db->prepare($sql);
         if (!$this->stmt) {
             \core\Handler::appException('pdo prepare error with:' . $sql);
             throw new \Exception("system error", '49903');
         }
         // 參數綁定
         !$params or $this->bindValue($params);
         // 輸出調試
         !$debug or $this->debug($sql, $params);
         // 執行一條sql語句
         if ($this->stmt->execute()) {
             // 設置解析模式
             $this->stmt->setFetchMode(\PDO::FETCH_CLASS, $class);
         } else {
             throw new \Exception('system error', '49904');
             // 獲取數據庫錯誤信息
             \core\Handler::appException($this->stmt->errorInfo()[2]);
         }
     } catch (\Exception $e) {
         \core\Handler::appException($e->getMessage());
         throw new \Exception('system error', '49902');
     }
 }
開發者ID:nicklos17,項目名稱:eapi,代碼行數:36,代碼來源:ModelBase.php

示例3: count

 /**
  * Get Total Number Of Records in Requested Table
  * 
  * @param string $sTable
  * @return number
  */
 public function count($sTable = '')
 {
     // if table name not pass
     if (!empty($sTable)) {
         // create count query
         $this->sSql = "SELECT COUNT(*) AS NUMROWS FROM {$sTable};";
         // pdo prepare statement
         $this->_oSTH = $this->prepare($this->sSql);
         try {
             if ($this->_oSTH->execute()) {
                 // fetch array result
                 $this->aResults = $this->_oSTH->fetch();
                 // close pdo
                 $this->_oSTH->closeCursor();
                 // return number of count
                 return $this->aResults['NUMROWS'];
             } else {
                 self::error($this->_oSTH->errorInfo());
             }
         } catch (PDOException $e) {
             // get pdo error and pass on error method
             self::error($e->getMessage() . ': ' . __LINE__);
         }
     } else {
         self::error('Table name not found..');
     }
 }
開發者ID:sahartak,項目名稱:storage,代碼行數:33,代碼來源:Database.php

示例4: _autoExecute

 /**
  * 執行操作的底層接口
  *
  * @param string $sql
  * @param array $params
  * @return PDO Statement
  */
 protected function _autoExecute($sql, $params = array())
 {
     try {
         $this->_getChoiceDbConnect();
         if (!$this->_db) {
             exit('DB connection lost.');
         }
         // 調試模式打印SQL信息
         $explain = array();
         if (Com_Db::enableLogging() && DEBUG_EXPLAIN_SQL) {
             $explain = $this->_explain($sql, $params);
         }
         $sqlStartTime = microtime(true);
         // 預編譯 SQL
         $stmt = $this->_db->prepare($sql);
         if (!$stmt) {
             exit(implode(',', $this->_db->errorInfo()));
         }
         // 綁定參數
         $params = $params ? (array) $params : array();
         // 執行 SQL
         if (!$stmt->execute($params)) {
             exit(implode(',', $stmt->errorInfo()));
         }
         $sqlCostTime = microtime(true) - $sqlStartTime;
         // 調試模式打印SQL信息
         if (Com_Db::enableLogging()) {
             Com_Db::sqlLog($this->_formatLogSql($sql, $params), $sqlCostTime, $explain);
         }
         return $stmt;
     } catch (Exception $e) {
         Com_Db_Exception::process($e, '[SQL Failed]', $this->_formatLogSql($sql, $params));
         return false;
     }
 }
開發者ID:645248882,項目名稱:CocoPHP,代碼行數:42,代碼來源:Pdo.php

示例5: _exectue

 /**
  * 執行SQL
  *
  * @param string $sSQL
  * @param array $aParam
  * @param boolean $bStrictMaster
  * @param boolean $bIsADU
  * @return unknown
  */
 protected function _exectue($sSQL, $aParam, $bStrictMaster, $bIsADU = false)
 {
     $iStartTime = microtime(true);
     ++self::$_iQueryCnt;
     self::$_aSQLs[] = $this->_sLastSQL = $sSQL;
     $db = $bStrictMaster ? $this->_getMasterDB() : $this->_getSlaveDB();
     $this->_oSth = $db->prepare($sSQL);
     if (!empty($aParam)) {
         $this->_bindParams($aParam);
     }
     $bRet = $this->_oSth->execute();
     if (false === $bRet) {
         $sMsg = 'SQL Error: ' . $this->_formatSQL($sSQL, $aParam) . "\n";
         $sMsg .= join("\n", $this->_oSth->errorInfo());
         throw new Exception($sMsg);
         return 0;
     }
     $iUseTime = round((microtime(true) - $iStartTime) * 1000, 2);
     self::$_iUseTime += $iUseTime;
     $iAffectedRows = $this->_oSth->rowCount();
     if ($this->_oDebug) {
         $this->_oDebug->debug('[DB->' . $this->_sDbName . ']: ' . $this->_formatSQL($sSQL, $aParam) . ' AffectedRows:' . $iAffectedRows . ' Use Time:' . $iUseTime . '毫秒');
     }
     // 記錄增刪改日誌
     if ($bIsADU) {
         self::_addADUSQL('[DB->' . $this->_sDbName . ']: ' . $this->_formatSQL($sSQL, $aParam) . ' AffectedRows:' . $iAffectedRows . ' Use Time:' . $iUseTime . '毫秒');
     }
     if ($iAffectedRows > 0 && $bIsADU) {
         $this->clearWhereCache();
     }
     return $iAffectedRows;
 }
開發者ID:pancke,項目名稱:yyaf,代碼行數:41,代碼來源:Orm.php

示例6: query

 /**
  * Prepare and execute query.
  *
  * @param string $sql     SQL string to query.
  * @param array  $params  Omit to do a normal query instead of a PDO prepared query.
  *
  * @return resource
  */
 public function query($sql, $params = null)
 {
     if (!$params) {
         $this->resultset = $this->dbh->query($sql);
     } else {
         $stmt = $this->dbh->prepare($sql);
         if (!empty($params)) {
             foreach ($params as $column => $param) {
                 if (is_int($params[$column])) {
                     $type = PDO::PARAM_INT;
                 } else {
                     if (is_null($params[$column]) || $params[$column] === null) {
                         $type = PDO::PARAM_NULL;
                     } else {
                         $type = PDO::PARAM_STR;
                     }
                 }
                 $stmt->bindValue(':' . $column, $params[$column], $type);
             }
         }
         $stmt->execute();
         $this->resultset = $stmt;
         if ($this->debug) {
             var_dump($params);
         }
     }
     if ($this->debug) {
         echo '<strong style="color: #dd0000;">' . $sql . '</strong> :: ' . implode(', ', $this->dbh->errorInfo()) . '<br /><br />';
     }
     return $this->resultset;
 }
開發者ID:JCquence,項目名稱:Clockwork,代碼行數:39,代碼來源:Database.php

示例7: checkAndRepairTable

 /**
  * Repairs and reindexes the table.  This might take a long time on a very large table.
  * @var string $tableName The name of the table.
  * @return boolean Return true if the table has integrity after the method is complete.
  */
 public function checkAndRepairTable($tableName = null)
 {
     $ok = true;
     if (!SapphireTest::using_temp_db() && !self::$checked_and_repaired) {
         $this->alterationMessage("Checking database integrity", "repaired");
         if ($msgs = $this->query('PRAGMA integrity_check')) {
             foreach ($msgs as $msg) {
                 if ($msg['integrity_check'] != 'ok') {
                     Debug::show($msg['integrity_check']);
                     $ok = false;
                 }
             }
         }
         if (self::$vacuum) {
             $this->query('VACUUM', E_USER_NOTICE);
             if ($this instanceof SQLitePDODatabase) {
                 $msg = $this->dbConn->errorInfo();
                 $msg = isset($msg[2]) ? $msg[2] : 'no errors';
             } else {
                 $msg = $this->dbConn->lastErrorMsg();
             }
             if (preg_match('/authoriz/', $msg)) {
                 $this->alterationMessage('VACUUM | ' . $msg, "error");
             } else {
                 $this->alterationMessage("VACUUMing", "repaired");
             }
         }
         self::$checked_and_repaired = true;
     }
     return $ok;
 }
開發者ID:rodneyway,項目名稱:front-end-workflow-testing,代碼行數:36,代碼來源:SQLite3Database.php

示例8:

 /**
  * Return an error string.
  *
  * @param resource The query resource.
  * @return int The error string of the current error.
  */
 function error_string($query)
 {
     if (!is_object($query) || !method_exists($query, "errorInfo")) {
         return $this->db->errorInfo();
     }
     return $query->errorInfo();
 }
開發者ID:ThinhNguyenVB,項目名稱:Gradient-Studios-Website,代碼行數:13,代碼來源:db_pdo.php

示例9: lastError

 /**
  * 獲取數據庫錯誤描述信息
  *
  * @access public
  *
  * @param PDOStatement $query
  *
  * @return string
  *
  * @example
  * 例一:
  * $erronInfo = $this->lastError();
  *
  * 例二:
  * $sth = $this->_dbLink->prepare('select * from tablename');
  * $sth->execute();
  *
  * $erronInfo = $this->lastError($sth);
  *
  */
 public function lastError(PDOStatement $query = null)
 {
     $error = !$query ? $this->_dbLink->errorInfo() : $query->errorInfo();
     if (!$error[2]) {
         return null;
     }
     return $error[1] . ': ' . $error[2];
 }
開發者ID:jinchunguang,項目名稱:doitphp_standard_v3,代碼行數:28,代碼來源:DbPdo.php

示例10: rollBack

 public static function rollBack()
 {
     try {
         if (!self::$instance instanceof \PDO) {
             throw new \PDOException(self::$exception['no-instance']);
         }
         if (!self::$instance->rollBack()) {
             throw new \PDOException(current(self::$instance->errorInfo()) . ' ' . end(self::$instance->errorInfo()));
         }
     } catch (\PDOException $e) {
         self::stackTrace($e);
     }
 }
開發者ID:giovanniramos,項目名稱:pdo4you,代碼行數:13,代碼來源:PDO4You.php

示例11: readUserData

 /**
  * Reads user data from the given data source
  * If only $handle is given, it will read the data
  * from the first user with that handle and return
  * true on success.
  * If $handle and $passwd are given, it will try to
  * find the first user with both handle and password
  * matching and return true on success (this allows
  * multiple users having the same handle but different
  * passwords - yep, some people want this).
  * if only an auth_user_id is passed it will try to read the data based on the id
  * If no match is found, false is being returned.
  *
  * @param  string user handle
  * @param  string user password
  * @param  bool|int if the user data should be read using the auth user id
  * @return bool true on success or false on failure
  *
  * @access public
  */
 function readUserData($handle = '', $passwd = '', $auth_user_id = false)
 {
     $fields = array();
     foreach ($this->tables['users']['fields'] as $field => $req) {
         $fields[] = $this->alias[$field] . ' AS ' . $field;
     }
     // Setting the default query.
     $query = 'SELECT ' . implode(',', $fields) . '
                FROM ' . $this->prefix . $this->alias['users'] . '
                WHERE  ';
     if ($auth_user_id) {
         $query .= $this->alias['auth_user_id'] . '=' . $this->dbc->quote($auth_user_id);
     } else {
         if (!is_array($this->handles) || empty($this->handles)) {
             $this->stack->push(LIVEUSER_ERROR_CONFIG, 'exception', array('reason' => 'No handle set in storage config.'));
             return false;
         }
         $handles = array();
         foreach ($this->handles as $field) {
             $handles[] = $this->alias[$field] . '=' . $this->dbc->quote($handle);
         }
         $query .= '(' . implode(' OR ', $handles) . ')';
         if (!is_null($this->tables['users']['fields']['passwd'])) {
             // If $passwd is set, try to find the first user with the given
             // handle and password.
             $query .= ' AND   ' . $this->alias['passwd'] . '=' . $this->dbc->quote($this->encryptPW($passwd));
         }
     }
     // Query database
     $res = $this->dbc->query($query);
     if ($res === false) {
         $error_info = $this->dbc->errorInfo();
         $this->stack->push(LIVEUSER_ERROR, 'exception', array('reason' => $error_info[2], 'debug' => $query));
         return false;
     }
     $result = $res->fetch(PDO::FETCH_ASSOC);
     if ($result === false && $this->dbc->errorCode() != '00000') {
         $this->stack->push(LIVEUSER_ERROR, 'exception', array('reason' => $this->dbc->errorCode(), 'debug' => $this->dbc->errorInfo()));
         return false;
     }
     if (!is_array($result)) {
         return null;
     }
     // User was found, read data into class variables and set return value to true
     if (array_key_exists('lastlogin', $result) && !empty($result['lastlogin'])) {
         $result['lastlogin'] = strtotime($result['lastlogin']);
     }
     $this->propertyValues = $result;
     return true;
 }
開發者ID:BackupTheBerlios,項目名稱:flushcms,代碼行數:70,代碼來源:PDO.php

示例12: execute

 /**
  * 執行SQL語句
  * @param string $sql 要執行的sql語句
  * @param array | boolean $param 當執行參數化查詢時需要的參數
  * @see PDO::exec()
  */
 public function execute($sql, $param = null)
 {
     $this->queries++;
     if (empty($sql) && $this->debug) {
         debug_print_backtrace();
         exit;
     }
     $this->lastSql[$this->lastSqlNameSpace] = $sql;
     $this->lastSqlParam[$this->lastSqlNameSpace] = $param;
     if (is_null($param)) {
         $this->rows = $this->pdo->exec($sql);
         if ($this->rows === false) {
             $this->errors = $this->pdo->errorInfo();
             // 				if (in_array($this->errors[1], $this->logSqlcodes)) {
             // 					$this->errors['sql'] = $sql;
             // 					$this->errors['params'] = $param;
             // 				}
             $this->errors($this->errors);
             return false;
         } else {
             return true;
         }
     } else {
         $this->stmt = $this->pdo->prepare($sql);
         if (is_array($param)) {
             $paramList = array();
             foreach ($param as $k => $v) {
                 $paramList[$k] = $v;
             }
             $param = $paramList;
             $result = $this->stmt->execute($param);
         } else {
             $result = $this->stmt->execute();
         }
         if (false === $result) {
             $this->errors = $this->stmt->errorInfo();
             $this->errors['sql'] = $sql;
             $this->errors['params'] = $param;
             $this->rows = 0;
         } else {
             $this->errors = null;
             $this->rows = $this->stmt->rowCount();
         }
         return $result;
     }
 }
開發者ID:noikiy,項目名稱:dophin,代碼行數:52,代碼來源:Mysql.class.php

示例13: query

 /**
  * 執行sql查詢
  * @param string sql語句
  * @param array 參數數組
  * @return void
  */
 public function query($sql, $params = array())
 {
     // 預處理綁定語句
     $this->stmt = $this->pdo->prepare($sql);
     // 參數綁定
     !$params or $this->bindValue($params);
     // 輸出調試
     !defined('SQL_ECHO') or $this->debug($sql, $params);
     // 執行一條sql語句
     if ($this->stmt->execute()) {
         // 設置解析模式
         $this->stmt->setFetchMode(\PDO::FETCH_CLASS, 'stdClass');
     } else {
         // 拋出一個pdo錯誤
         throw new \PDOException($this->stmt->errorInfo()[2]);
     }
 }
開發者ID:sinfey69,項目名稱:enyphp,代碼行數:23,代碼來源:Mysql.php

示例14: update_password

 /**
  * Update Password
  *
  * Run a query to update a password.
  *
  * @param       int $user_account_password    The data value
  * @param       int $user_account_id          The data value
  * @param       string $emailed_hash          The data value
  * @return      null|boolean                  True/False
  */
 public function update_password($user_account_password = false, $user_account_id = false, $emailed_hash = false)
 {
     $updated = false;
     if ($user_account_id && $emailed_hash) {
         // UPDATE the emailed_hash in the user_account table.
         $statement = $this->db->prepare("UPDATE user_account\n              SET user_account_password = :user_account_password, active = 1\n              WHERE user_account_id = :user_account_id\n              AND emailed_hash = :emailed_hash");
         $statement->bindValue(":user_account_password", $user_account_password, PDO::PARAM_STR);
         $statement->bindValue(":user_account_id", $user_account_id, PDO::PARAM_INT);
         $statement->bindValue(":emailed_hash", $emailed_hash, PDO::PARAM_STR);
         $statement->execute();
         $error = $this->db->errorInfo();
         if ($error[0] != "00000") {
             die('The UPDATE user_account password query failed.');
         }
         $updated = true;
     }
     return $updated;
 }
開發者ID:ghalusa,項目名稱:php-skeleton-app,代碼行數:28,代碼來源:register_account.class.php

示例15: findQuery

 /**
  * Useful for searching.
  *
  * @param string $table is the table name
  * @param array $where $where is an optional array
  * of parameters to be feed the where statement
  * example: array('name'=>'john')
  * @return array of rows
  */
 public function findQuery($table, array $where)
 {
     $query = "SELECT * FROM {$table} WHERE ";
     try {
         if (!empty($where)) {
             foreach ($where as $field => $value) {
                 $query .= " {$field} LIKE :{$field} OR";
             }
             $query = substr($query, 0, -3);
         }
         $stmt = $this->connection->prepare($query);
         if ($stmt->execute($where)) {
             return $stmt->fetchAll(\PDO::FETCH_ASSOC);
         }
         return array();
     } catch (\PDOException $ex) {
         $this->setErrors($this->connection->errorInfo()[2]);
         return array();
     }
 }
開發者ID:anasshekhamis,項目名稱:Basically-CRUD,代碼行數:29,代碼來源:Database.php


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