本文整理汇总了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;
}
示例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;
}
}
示例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;
}
示例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();
}