当前位置: 首页>>代码示例>>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;未经允许,请勿转载。