• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP pg_result_error_field函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中pg_result_error_field函数的典型用法代码示例。如果您正苦于以下问题:PHP pg_result_error_field函数的具体用法?PHP pg_result_error_field怎么用?PHP pg_result_error_field使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了pg_result_error_field函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: castResult

 public static function castResult($result, array $a, Stub $stub, $isNested)
 {
     $a['num rows'] = pg_num_rows($result);
     $a['status'] = pg_result_status($result);
     if (isset(self::$resultStatus[$a['status']])) {
         $a['status'] = new ConstStub(self::$resultStatus[$a['status']], $a['status']);
     }
     $a['command-completion tag'] = pg_result_status($result, PGSQL_STATUS_STRING);
     if (-1 === $a['num rows']) {
         foreach (self::$diagCodes as $k => $v) {
             $a['error'][$k] = pg_result_error_field($result, $v);
         }
     }
     $a['affected rows'] = pg_affected_rows($result);
     $a['last OID'] = pg_last_oid($result);
     $fields = pg_num_fields($result);
     for ($i = 0; $i < $fields; ++$i) {
         $field = array('name' => pg_field_name($result, $i), 'table' => sprintf('%s (OID: %s)', pg_field_table($result, $i), pg_field_table($result, $i, true)), 'type' => sprintf('%s (OID: %s)', pg_field_type($result, $i), pg_field_type_oid($result, $i)), 'nullable' => (bool) pg_field_is_null($result, $i), 'storage' => pg_field_size($result, $i) . ' bytes', 'display' => pg_field_prtlen($result, $i) . ' chars');
         if (' (OID: )' === $field['table']) {
             $field['table'] = null;
         }
         if ('-1 bytes' === $field['storage']) {
             $field['storage'] = 'variable size';
         } elseif ('1 bytes' === $field['storage']) {
             $field['storage'] = '1 byte';
         }
         if ('1 chars' === $field['display']) {
             $field['display'] = '1 char';
         }
         $a['fields'][] = new EnumStub($field);
     }
     return $a;
 }
开发者ID:JesseDarellMoore,项目名称:CS499,代码行数:33,代码来源:PgSqlCaster.php


示例2: query

 /**
  * 执行数据库查询
  *
  * @param string $query 数据库查询SQL字符串
  * @param mixed $handle 连接对象
  * @param integer $op 数据库读写状态
  * @param string $action 数据库动作
  * @throws Typecho_Db_Exception
  * @return resource
  */
 public function query($query, $handle, $op = Typecho_Db::READ, $action = NULL)
 {
     $isQueryObject = $query instanceof Typecho_Db_Query;
     $this->_lastTable = $isQueryObject ? $query->getAttribute('table') : NULL;
     if ($resource = @pg_query($handle, $isQueryObject ? $query->__toString() : $query)) {
         return $resource;
     }
     /** 数据库异常 */
     throw new Typecho_Db_Query_Exception(@pg_last_error($this->_dbLink), pg_result_error_field(pg_get_result($this->_dbLink), PGSQL_DIAG_SQLSTATE));
 }
开发者ID:r0ker,项目名称:hctf2015-all-problems,代码行数:20,代码来源:Pgsql.php


示例3: rawQuery

 public function rawQuery($sql, array $params = [])
 {
     if (empty($params)) {
         pg_send_query($this->dbconn, $sql);
     } else {
         pg_send_query_params($this->dbconn, $sql, $params);
     }
     $result = pg_get_result($this->dbconn);
     $err = pg_result_error($result);
     if ($err) {
         throw new \Pg\Exception($err, 0, null, pg_result_error_field($result, PGSQL_DIAG_SQLSTATE));
     }
     return new \Pg\Statement($result, $this->typeConverter);
 }
开发者ID:aoyagikouhei,项目名称:pg,代码行数:14,代码来源:Db.php


示例4: query

 public static function query($query)
 {
     try {
         $result = \pg_query(self::instance(), $query);
         if (!$result) {
             print_r(debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 1));
         }
     } catch (\Exception $e) {
         throw new \Exception("not executed: " . $query);
     }
     $error = \pg_result_error_field($result, PGSQL_DIAG_SQLSTATE);
     if ($error) {
         throw new \Exception($error);
     }
     return new Result($result);
 }
开发者ID:yuzic,项目名称:aqua-framework,代码行数:16,代码来源:Connection.php


示例5: query

 public function query($query)
 {
     if (!pg_send_query($this->connection, $query)) {
         throw $this->createException(pg_last_error($this->connection), 0, NULL);
     }
     $time = microtime(TRUE);
     $resource = pg_get_result($this->connection);
     $time = microtime(TRUE) - $time;
     if ($resource === FALSE) {
         throw $this->createException(pg_last_error($this->connection), 0, NULL);
     }
     $state = pg_result_error_field($resource, PGSQL_DIAG_SQLSTATE);
     if ($state !== NULL) {
         throw $this->createException(pg_result_error($resource), 0, $state, $query);
     }
     $this->affectedRows = pg_affected_rows($resource);
     return new Result(new PgsqlResultAdapter($resource), $this, $time);
 }
开发者ID:jasir,项目名称:dbal,代码行数:18,代码来源:PgsqlDriver.php


示例6: ejecutarValidandoUniqueANDPrimaryKey

 function ejecutarValidandoUniqueANDPrimaryKey($sql)
 {
     if ($sql == "") {
         return 0;
     } else {
         /* Si puede enviar la consulta sin importar que encuentre llaves duplicadas */
         if (pg_send_query($this->connect, $sql)) {
             /* Ejecuta la consulta */
             $this->consulta_ID = pg_get_result($this->connect);
             /* Se tiene algun resultado sin importar que contenga errores de duplidados */
             if ($this->consulta_ID) {
                 /* Detecte un posible error */
                 $state = pg_result_error_field($this->consulta_ID, PGSQL_DIAG_SQLSTATE);
                 /* Si no se genero ningun error */
                 if ($state == 0) {
                     return $this->consulta_ID;
                 } else {
                     /* Si encontro algun error */
                     return false;
                 }
             }
         }
     }
 }
开发者ID:johnny9052,项目名称:loguinMasterPagePhpRegistroAjaxDAOPDF,代码行数:24,代码来源:clsConexion.php


示例7: error_number

 /**
  * Return an error number.
  *
  * @param resource $query
  * @return int The error number of the current error.
  */
 function error_number($query = null)
 {
     if ($query != null || !function_exists("pg_result_error_field")) {
         return 0;
     }
     return pg_result_error_field($query, PGSQL_DIAG_SQLSTATE);
 }
开发者ID:mainhan1804,项目名称:xomvanphong,代码行数:13,代码来源:db_pgsql.php


示例8: wpsql_errno

function wpsql_errno($connection)
{
    //		throw new Exception("Error Processing Request", 1);
    if ($connection == 1) {
        return false;
    }
    $result = pg_get_result($connection);
    $result_status = pg_result_status($result);
    return pg_result_error_field($result_status, PGSQL_DIAG_SQLSTATE);
}
开发者ID:gowrav-vishwakarma,项目名称:wp_clusterpoint,代码行数:10,代码来源:driver_clusterpoint_4.0.php


示例9: session_start

<?php

session_start();
include 'conexion.php';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $query = 'INSERT INTO tiposcontactos (id_tipocontacto, nombre, estado)' . " VALUES ((SELECT cargarRegistro('TiposContactos')),'" . $_POST['tipo_contacto'] . "', true)";
    conectarBD();
    if (pg_send_query($conexion, $query)) {
        $resultado = pg_get_result($conexion);
        if ($resultado) {
            $estado = pg_result_error_field($resultado, PGSQL_DIAG_SQLSTATE);
            if ($estado == 0) {
                // En caso de que no haya ningún error.
                $_SESSION['error_bd'] = false;
                $_SESSION['insert_successful'] = true;
                $_SESSION['success_msg'] = "Contacto agregado exitosamente.";
            } else {
                //Hay algún error.
                $_SESSION['error_bd'] = true;
                $_SESSION['estado'] = $estado;
                if ($estado == "23505") {
                    $_SESSION['estado'] = "Violación de valor único";
                    // Violación de estado único.
                }
            }
        } else {
            $_SESSION['error_bd'] = true;
            $_SESSION['estado'] = "Error Desconocido";
        }
        header('Location: mantenimientos.php');
    }
开发者ID:pornuestropais,项目名称:PHPCRM,代码行数:31,代码来源:do_agregar_tipocontacto.php


示例10: performQuery

 /**
  * @throws DBQueryException
  * @param ISqlQUery $query
  * @param boolean $isAsync
  * @return resource
  */
 protected function performQuery(ISqlQuery $query, $isAsync)
 {
     Assert::isBoolean($isAsync);
     $parameters = $query->getPlaceholderValues($this->getDialect());
     $queryAsString = $query->toDialectString($this->getDialect());
     if ($isAsync) {
         LoggerPool::log(parent::LOG_VERBOSE, 'sending an async query: %s', $queryAsString);
     } else {
         LoggerPool::log(parent::LOG_VERBOSE, 'sending query: %s', $queryAsString);
     }
     LoggerPool::log(parent::LOG_QUERY, $queryAsString);
     $executeResult = pg_send_query($this->link, $queryAsString);
     if (!$isAsync || !$executeResult) {
         $result = pg_get_result($this->link);
         $resultStatus = pg_result_status($result, PGSQL_STATUS_LONG);
         if (in_array($resultStatus, array(PGSQL_EMPTY_QUERY, PGSQL_BAD_RESPONSE, PGSQL_NONFATAL_ERROR, PGSQL_FATAL_ERROR))) {
             $errorCode = pg_result_error_field($result, PGSQL_DIAG_SQLSTATE);
             $errorMessage = pg_result_error_field($result, PGSQL_DIAG_MESSAGE_PRIMARY);
             if (PgSqlError::UNIQUE_VIOLATION == $errorCode) {
                 LoggerPool::log(parent::LOG_VERBOSE, 'query caused a unique violation: %s', $errorMessage);
                 throw new UniqueViolationException($query, $errorMessage);
             } else {
                 LoggerPool::log(parent::LOG_VERBOSE, 'query caused an error #%s: %s', $errorCode, $errorMessage);
                 throw new PgSqlQueryException($query, $errorMessage, $errorCode);
             }
         }
     }
     return $result;
 }
开发者ID:phoebius,项目名称:ajax-example,代码行数:35,代码来源:PgSqlDB.class.php


示例11: query

 private function query($query, $etypeDirty = null)
 {
     while (pg_get_result($this->link)) {
         // Clear the connection of all results.
         continue;
     }
     if (!pg_send_query($this->link, $query)) {
         throw new Exceptions\QueryFailedException('Query failed: ' . pg_last_error(), 0, null, $query);
     }
     if (!($result = pg_get_result($this->link))) {
         throw new Exceptions\QueryFailedException('Query failed: ' . pg_last_error(), 0, null, $query);
     }
     if ($error = pg_result_error_field($result, PGSQL_DIAG_SQLSTATE)) {
         // If the tables don't exist yet, create them.
         if ($error == '42P01' && $this->createTables()) {
             if (isset($etypeDirty)) {
                 $this->createTables($etypeDirty);
             }
             if (!($result = pg_query($this->link, $query))) {
                 throw new Exceptions\QueryFailedException('Query failed: ' . pg_last_error(), 0, null, $query);
             }
         } else {
             throw new Exceptions\QueryFailedException('Query failed: ' . pg_last_error(), 0, null, $query);
         }
     }
     return $result;
 }
开发者ID:sciactive,项目名称:nymph-server,代码行数:27,代码来源:PostgreSQLDriver.php


示例12: execute

 /**
  * Execute the SQL statement.
  *
  * @return  mixed  A database cursor resource on success, boolean false on failure.
  *
  * @since   1.0
  * @throws  \RuntimeException
  */
 public function execute()
 {
     $this->connect();
     // Take a local copy so that we don't modify the original query and cause issues later
     $sql = $this->replacePrefix((string) $this->sql);
     if ($this->limit > 0 || $this->offset > 0) {
         $sql .= ' LIMIT ' . $this->limit . ' OFFSET ' . $this->offset;
     }
     $count = $this->getCount();
     // Increment the query counter.
     $this->count++;
     // If debugging is enabled then let's log the query.
     if ($this->debug) {
         // Add the query to the object queue.
         $this->log(Log\LogLevel::DEBUG, '{sql}', array('sql' => $sql, 'category' => 'databasequery', 'trace' => debug_backtrace()));
     }
     // Reset the error values.
     $this->errorNum = 0;
     $this->errorMsg = '';
     // Bind the variables
     if ($this->sql instanceof PreparableInterface) {
         $bounded =& $this->sql->getBounded();
         if (count($bounded)) {
             // Execute the query. Error suppression is used here to prevent warnings/notices that the connection has been lost.
             $this->cursor = @pg_execute($this->connection, $this->queryName . $count, array_values($bounded));
         } else {
             // Execute the query. Error suppression is used here to prevent warnings/notices that the connection has been lost.
             $this->cursor = @pg_query($this->connection, $sql);
         }
     } else {
         // Execute the query. Error suppression is used here to prevent warnings/notices that the connection has been lost.
         $this->cursor = @pg_query($this->connection, $sql);
     }
     // If an error occurred handle it.
     if (!$this->cursor) {
         // Check if the server was disconnected.
         if (!$this->connected()) {
             try {
                 // Attempt to reconnect.
                 $this->connection = null;
                 $this->connect();
             } catch (ConnectionFailureException $e) {
                 // Get the error number and message.
                 $this->errorNum = (int) pg_result_error_field($this->cursor, PGSQL_DIAG_SQLSTATE) . ' ';
                 $this->errorMsg = pg_last_error($this->connection);
                 // Throw the normal query exception.
                 $this->log(Log\LogLevel::ERROR, 'Database query failed (error #{code}): {message}; Failed query: {sql}', array('code' => $this->errorNum, 'message' => $this->errorMsg, 'sql' => $sql));
                 throw new ExecutionFailureException($sql, $this->errorMsg);
             }
             // Since we were able to reconnect, run the query again.
             return $this->execute();
         } else {
             // Get the error number and message.
             $this->errorNum = (int) pg_result_error_field($this->cursor, PGSQL_DIAG_SQLSTATE) . ' ';
             $this->errorMsg = pg_last_error($this->connection) . "\nSQL={$sql}";
             // Throw the normal query exception.
             $this->log(Log\LogLevel::ERROR, 'Database query failed (error #{code}): {message}; Failed query: {sql}', array('code' => $this->errorNum, 'message' => $this->errorMsg, 'sql' => $sql));
             throw new ExecutionFailureException($sql, $this->errorMsg);
         }
     }
     return $this->cursor;
 }
开发者ID:jbanety,项目名称:database,代码行数:70,代码来源:PostgresqlDriver.php


示例13: wpsql_errno

function wpsql_errno($connection)
{
    $result = pg_get_result($connection);
    $result_status = pg_result_status($result);
    return pg_result_error_field($result_status, PGSQL_DIAG_SQLSTATE);
}
开发者ID:PulseSoftwareInc,项目名称:wordpress-heroku,代码行数:6,代码来源:driver_pgsql.php


示例14: dbError

 /**
  * Returns a database error message
  *
  * @param    string      $sql    SQL that may have caused the error
  * @return   string      Text for error message
  *
  */
 function dbError($sql = '')
 {
     $result = pg_get_result($this->_db);
     if ($this->_pgsql_version >= 7.4) {
         // this provides a much more detailed error report
         if (pg_result_error_field($result, PGSQL_DIAG_SOURCE_LINE)) {
             $this->_errorlog('You have an error in your SQL query on line ' . pg_result_error_field($result, PGSQL_DIAG_SOURCE_LINE) . "\nSQL in question: {$sql}");
             $this->_errorlog('Error: ' . pg_result_error_field($result, PGSQL_DIAG_SQLSTATE) . "\nDescription: " . pg_result_error_field($result, PGSQL_DIAG_MESSAGE_DETAIL));
             if ($this->_display_error) {
                 $error = "An SQL error has occurred in the following SQL: {$sql}";
             } else {
                 $error = 'An SQL error has occurred. Please see error.log for details.';
             }
             return $error;
         }
     } else {
         if (pg_result_error($result)) {
             $this->_errorlog(pg_result_error($result) . ". SQL in question: {$sql}");
             if ($this->_display_error) {
                 $error = 'Error ' . pg_result_error($result);
             } else {
                 $error = 'An SQL error has occurred. Please see error.log for details.';
             }
             return $error;
         }
     }
     return;
 }
开发者ID:alxstuart,项目名称:ajfs.me,代码行数:35,代码来源:pgsql.class.php


示例15: execute

	/**
	 * Execute the SQL statement.
	 *
	 * @return  mixed  A database cursor resource on success, boolean false on failure.
	 *
	 * @since   12.1
	 * @throws  RuntimeException
	 */
	public function execute()
	{
		$this->connect();

		if (!is_resource($this->connection))
		{
			JLog::add(JText::sprintf('JLIB_DATABASE_QUERY_FAILED', $this->errorNum, $this->errorMsg), JLog::ERROR, 'database');
			throw new RuntimeException($this->errorMsg, $this->errorNum);
		}

		// Take a local copy so that we don't modify the original query and cause issues later
		$sql = $this->replacePrefix((string) $this->sql);

		if ($this->limit > 0 || $this->offset > 0)
		{
			$sql .= ' LIMIT ' . $this->limit . ' OFFSET ' . $this->offset;
		}

		// Increment the query counter.
		$this->count++;

		// If debugging is enabled then let's log the query.
		if ($this->debug)
		{
			// Add the query to the object queue.
			$this->log[] = $sql;

			JLog::add($sql, JLog::DEBUG, 'databasequery');
		}

		// Reset the error values.
		$this->errorNum = 0;
		$this->errorMsg = '';

		// Execute the query. Error suppression is used here to prevent warnings/notices that the connection has been lost.
		$this->cursor = @pg_query($this->connection, $sql);

		// If an error occurred handle it.
		if (!$this->cursor)
		{
			// Check if the server was disconnected.
			if (!$this->connected())
			{
				try
				{
					// Attempt to reconnect.
					$this->connection = null;
					$this->connect();
				}
				// If connect fails, ignore that exception and throw the normal exception.
				catch (RuntimeException $e)
				{
					// Get the error number and message.
					$this->errorNum = (int) pg_result_error_field($this->cursor, PGSQL_DIAG_SQLSTATE) . ' ';
					$this->errorMsg = JText::_('JLIB_DATABASE_QUERY_FAILED') . "\n" . pg_last_error($this->connection) . "\nSQL=$sql";

					// Throw the normal query exception.
					JLog::add(JText::sprintf('JLIB_DATABASE_QUERY_FAILED', $this->errorNum, $this->errorMsg), JLog::ERROR, 'databasequery');
					throw new RuntimeException($this->errorMsg);
				}

				// Since we were able to reconnect, run the query again.
				return $this->execute();
			}
			// The server was not disconnected.
			else
			{
				// Get the error number and message.
				$this->errorNum = (int) pg_result_error_field($this->cursor, PGSQL_DIAG_SQLSTATE) . ' ';
				$this->errorMsg = JText::_('JLIB_DATABASE_QUERY_FAILED') . "\n" . pg_last_error($this->connection) . "\nSQL=$sql";

				// Throw the normal query exception.
				JLog::add(JText::sprintf('JLIB_DATABASE_QUERY_FAILED', $this->errorNum, $this->errorMsg), JLog::ERROR, 'databasequery');
				throw new RuntimeException($this->errorMsg);
			}
		}

		return $this->cursor;
	}
开发者ID:realityking,项目名称:joomla-platform,代码行数:87,代码来源:postgresql.php


示例16: sql_query

 function sql_query($query = "", $transaction = false)
 {
     //
     // Remove any pre-existing queries
     //
     unset($this->query_result);
     if ($query != "") {
         $this->num_queries++;
         $query = preg_replace("/LIMIT ([0-9]+),([ 0-9]+)/", "LIMIT \\2 OFFSET \\1", $query);
         if ($transaction == BEGIN_TRANSACTION && !$this->in_transaction) {
             $this->in_transaction = TRUE;
             if (!@pg_query($this->db_connect_id, "BEGIN")) {
                 return false;
             }
         }
         //echo "DB" ;print_r($this);
         if (pg_send_query($this->db_connect_id, $query)) {
             $this->query_result = pg_get_result($this->db_connect_id);
             $error_code = pg_result_error_field($this->query_result, PGSQL_DIAG_SQLSTATE);
         }
         //$this->query_result = @pg_query($this->db_connect_id, $query);
         if (!$error_code) {
             if ($transaction == END_TRANSACTION) {
                 $this->in_transaction = FALSE;
                 if (!@pg_query($this->db_connect_id, "COMMIT")) {
                     @pg_query($this->db_connect_id, "ROLLBACK");
                     return false;
                 }
             }
             $this->last_query_text[$this->query_result] = $query;
             $this->rownum[$this->query_result] = 0;
             unset($this->row[$this->query_result]);
             unset($this->rowset[$this->query_result]);
             return $this->query_result;
         } else {
             if ($this->in_transaction) {
                 @pg_query($this->db_connect_id, "ROLLBACK");
             }
             $this->in_transaction = FALSE;
             /*pg_send_query($this->db_connect_id, $query);
             		$result = pg_get_result($this->db_connect_id);
             		$code=pg_result_error_field($result, PGSQL_DIAG_SQLSTATE);*/
             $this->error_message[] = array("code" => $error_code, "text" => pg_result_error($this->query_result), "query" => $query);
             return false;
         }
     } else {
         if ($transaction == END_TRANSACTION && $this->in_transaction) {
             $this->in_transaction = FALSE;
             if (!@pg_query($this->db_connect_id, "COMMIT")) {
                 @pg_query($this->db_connect_id, "ROLLBACK");
                 return false;
             }
         }
         return true;
     }
 }
开发者ID:mamogmx,项目名称:praticaweb-alghero,代码行数:56,代码来源:postgres.php


示例17: _error

 /**
  * Prints error message $error to debug system.
  * @param string $query The query that was attempted, will be printed if
  *                      $error is \c false
  * @param PDOStatement|resource $res The result resource the error occurred on
  * @param string $fname The function name that started the query, should
  *                      contain relevant arguments in the text.
  * @param string $error The error message, if this is an array the first
  *                      element is the value to dump and the second the error
  *                      header (for eZDebug::writeNotice). If this is \c
  *                      false a generic message is shown.
  */
 protected function _error($query, $res, $fname, $error = "Failed to execute SQL for function:")
 {
     if ($error === false) {
         $error = "Failed to execute SQL for function:";
     } else {
         if (is_array($error)) {
             $fname = $error[1];
             $error = $error[0];
         }
     }
     // @todo Investigate error methods
     eZDebug::writeError("{$error}\n" . pg_result_error_field($res, PGSQL_DIAG_SQLSTATE) . ': ' . pg_result_error_field($res, PGSQL_DIAG_MESSAGE_PRIMARY) . ' ' . $query, $fname);
 }
开发者ID:informaticatrentina,项目名称:ezpostgresqlcluster,代码行数:25,代码来源:ezpostsgresqlbackend.php


示例18: getPKId

 /**
 	Returns the primary key index value.
 
 	@param	$sName	The primary key index name, if needed.
 	@return	string	The primary key index value.
 	@throw	IllegalStateException	No value has been generated yet for the given sequence in this session.
 */
 public function getPKId($sName = null)
 {
     if ($sName === null) {
         $sQuery = 'SELECT pg_catalog.lastval()';
     } else {
         $sQuery = 'SELECT pg_catalog.currval(' . $this->escape($sName) . ')';
     }
     // We need to get the SQLSTATE returned by PostgreSQL so we can't use pg_query here.
     pg_send_query($this->rLink, $sQuery);
     $r = pg_get_result($this->rLink);
     $mSQLState = pg_result_error_field($r, PGSQL_DIAG_SQLSTATE);
     $mSQLState == '55000' and burn('IllegalStateException', _WT('PostgreSQL has not yet generated a value for the given sequence in this session.'));
     $mSQLState === null or burn('DatabaseException', sprintf(_WT("PostgreSQL failed to return the value of the given sequence with the following message:\n%s"), pg_last_error($this->rLink)));
     return pg_fetch_result($r, 0, 0);
 }
开发者ID:extend,项目名称:wee,代码行数:22,代码来源:weePgSQLDatabase.class.php


示例19: interact


//.........这里部分代码省略.........
         }
         if (!empty($PHORUM['DBCONFIG']['charset'])) {
             $charset = $PHORUM['DBCONFIG']['charset'];
             pg_query($conn, "SET CLIENT_ENCODING TO '{$charset}'");
         }
     }
     // RETURN: quoted parameter.
     if ($return === DB_RETURN_QUOTED) {
         return pg_escape_string($conn, $sql);
     }
     // RETURN: database connection handle.
     if ($return === DB_RETURN_CONN) {
         return $conn;
     }
     // By now, we really need a SQL query.
     if ($sql === NULL) {
         trigger_error(__METHOD__ . ': Internal error: ' . 'missing sql query statement!', E_USER_ERROR);
     }
     // Apply limit and offset to the query.
     settype($limit, 'int');
     settype($offset, 'int');
     if ($limit > 0) {
         $sql .= " LIMIT {$limit}";
     }
     if ($offset > 0) {
         $sql .= " OFFSET {$offset}";
     }
     // Execute the SQL query.
     if (!@pg_send_query($conn, $sql)) {
         trigger_error(__METHOD__ . ': Internal error: ' . 'pg_send_query() failed!', E_USER_ERROR);
     }
     // Check if an error occurred.
     $res = pg_get_result($conn);
     $errno = pg_result_error_field($res, PGSQL_DIAG_SQLSTATE);
     if ($errno != 0) {
         // See if the $flags tell us to ignore the error.
         $ignore_error = FALSE;
         switch ($errno) {
             // Table does not exist.
             case '42P01':
                 if ($flags & DB_MISSINGTABLEOK) {
                     $ignore_error = TRUE;
                 }
                 break;
                 // Table already exists or duplicate key name.
                 // These two cases use the same error code.
             // Table already exists or duplicate key name.
             // These two cases use the same error code.
             case '42P07':
                 if ($flags & DB_TABLEEXISTSOK) {
                     $ignore_error = TRUE;
                 }
                 if ($flags & DB_DUPKEYNAMEOK) {
                     $ignore_error = TRUE;
                 }
                 break;
                 // Duplicate column name.
             // Duplicate column name.
             case '42701':
                 if ($flags & DB_DUPFIELDNAMEOK) {
                     $ignore_error = TRUE;
                 }
                 break;
                 // Duplicate entry for key.
             // Duplicate entry for key.
             case '23505':
开发者ID:samuell,项目名称:Core,代码行数:67,代码来源:PhorumPostgresqlDB.php


示例20: getErrorNumber

 /**
  * Return the actual SQL Error number
  *
  * @return  integer  The SQL Error number
  *
  * @since   3.4.6
  */
 protected function getErrorNumber()
 {
     return (int) pg_result_error_field($this->cursor, PGSQL_DIAG_SQLSTATE) . ' ';
 }
开发者ID:adjaika,项目名称:J3Base,代码行数:11,代码来源:postgresql.php



注:本文中的pg_result_error_field函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP pg_result_seek函数代码示例发布时间:2022-05-15
下一篇:
PHP pg_result_error函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap