当前位置: 首页>>代码示例>>PHP>>正文


PHP pg_result_status函数代码示例

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


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

示例1: query

 function query($sql, $unbuffered = false)
 {
     if (strrpos($sql, 'LIMIT') !== false) {
         $sql = preg_replace('#LIMIT ([0-9]+),([ 0-9]+)#', 'LIMIT \\2 OFFSET \\1', $sql);
     }
     if (defined('PUN_SHOW_QUERIES')) {
         $q_start = get_microtime();
     }
     @pg_send_query($this->link_id, $sql);
     $this->query_result = @pg_get_result($this->link_id);
     if (pg_result_status($this->query_result) != PGSQL_FATAL_ERROR) {
         if (defined('PUN_SHOW_QUERIES')) {
             $this->saved_queries[] = array($sql, sprintf('%.5f', get_microtime() - $q_start));
         }
         ++$this->num_queries;
         $this->last_query_text[$this->query_result] = $sql;
         return $this->query_result;
     } else {
         if (defined('PUN_SHOW_QUERIES')) {
             $this->saved_queries[] = array($sql, 0);
         }
         $this->error_no = false;
         $this->error_msg = @pg_result_error($this->query_result);
         if ($this->in_transaction) {
             @pg_query($this->link_id, 'ROLLBACK');
         }
         --$this->in_transaction;
         return false;
     }
 }
开发者ID:highpictv,项目名称:forum,代码行数:30,代码来源:pgsql.php

示例2: 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

示例3: __construct

 public function __construct($result, $sql, $as_object = FALSE, $params = NULL, $total_rows = NULL)
 {
     parent::__construct($result, $sql, $as_object, $params);
     if ($as_object === TRUE) {
         $this->_as_object = 'stdClass';
     }
     if ($total_rows !== NULL) {
         $this->_total_rows = $total_rows;
     } else {
         switch (pg_result_status($result)) {
             case PGSQL_TUPLES_OK:
                 $this->_total_rows = pg_num_rows($result);
                 break;
             case PGSQL_COMMAND_OK:
                 $this->_total_rows = pg_affected_rows($result);
                 break;
             case PGSQL_BAD_RESPONSE:
             case PGSQL_NONFATAL_ERROR:
             case PGSQL_FATAL_ERROR:
                 throw new Database_Exception(':error [ :query ]', array(':error' => pg_result_error($result), ':query' => $sql));
             case PGSQL_COPY_OUT:
             case PGSQL_COPY_IN:
                 throw new Database_Exception('PostgreSQL COPY operations not supported [ :query ]', array(':query' => $sql));
             default:
                 $this->_total_rows = 0;
         }
     }
 }
开发者ID:alekseyshavrak,项目名称:3cx,代码行数:28,代码来源:Result.php

示例4: pg_query

 protected function &execute($query)
 {
     $result = pg_query($this->db, $query);
     if ($result === false) {
         throw new AleExceptionCache(pg_last_error($this->db), pg_result_status($result));
     }
     return $result;
 }
开发者ID:ni-c,项目名称:simpleve,代码行数:8,代码来源:pgsql.php

示例5: q

 function q($sql)
 {
     if (!$this->db || !$this->connected) {
         return false;
     }
     if (!strpos($sql, ';')) {
         $sql .= ';';
     }
     if (strpos($sql, '`')) {
         // this is a hack. quoted identifiers should be replaced everywhere in the code with dbesc_identifier(), remove this once it is
         $sql = str_replace('`', '"', $sql);
     }
     $this->error = '';
     $result = @pg_query($this->db, $sql);
     if (file_exists('db-allqueries.out')) {
         $bt = debug_backtrace();
         $trace = array();
         foreach ($bt as $frame) {
             if (!empty($frame['file']) && @strstr($frame['file'], $_SERVER['DOCUMENT_ROOT'])) {
                 $frame['file'] = substr($frame['file'], strlen($_SERVER['DOCUMENT_ROOT']) + 1);
             }
             $trace[] = $frame['file'] . ':' . $frame['function'] . '():' . $frame['line'];
         }
         $compact = join(', ', $trace);
         file_put_contents('db-allqueries.out', datetime_convert() . ": " . $sql . ' is_resource: ' . var_export(is_resource($result), true) . ', backtrace: ' . $compact . "\n\n", FILE_APPEND);
     }
     if ($result === false) {
         $this->error = pg_last_error($this->db);
     }
     if ($result === false || $this->error) {
         //logger('dba_postgres: ' . printable($sql) . ' returned false.' . "\n" . $this->error);
         if (file_exists('dbfail.out')) {
             file_put_contents('dbfail.out', datetime_convert() . "\n" . printable($sql) . ' returned false' . "\n" . $this->error . "\n", FILE_APPEND);
         }
     }
     if ($result === true || $result === false) {
         return $result;
     }
     if (pg_result_status($result) == PGSQL_COMMAND_OK) {
         return true;
     }
     $r = array();
     if (pg_num_rows($result)) {
         while ($x = pg_fetch_array($result, null, PGSQL_ASSOC)) {
             $r[] = $x;
         }
         pg_free_result($result);
         if ($this->debug) {
             logger('dba_postgres: ' . printable(print_r($r, true)));
         }
     }
     return $r;
 }
开发者ID:msooon,项目名称:hubzilla,代码行数:53,代码来源:dba_postgres.php

示例6: sqlCallback

/**
 * This is a callback function to display the result of each separate query
 * @param ADORecordSet $rs The recordset returned by the script execetor
 */
function sqlCallback($query, $rs, $lineno)
{
    global $data, $misc, $lang, $_connection;
    // Check if $rs is false, if so then there was a fatal error
    if ($rs === false) {
        echo htmlspecialchars($_FILES['script']['name']), ':', $lineno, ': ', nl2br(htmlspecialchars($_connection->getLastError())), "<br/>\n";
    } else {
        // Print query results
        switch (pg_result_status($rs)) {
            case PGSQL_TUPLES_OK:
                // If rows returned, then display the results
                $num_fields = pg_numfields($rs);
                echo "<p><table>\n<tr>";
                for ($k = 0; $k < $num_fields; $k++) {
                    echo "<th class=\"data\">", $misc->printVal(pg_fieldname($rs, $k)), "</th>";
                }
                $i = 0;
                $row = pg_fetch_row($rs);
                while ($row !== false) {
                    $id = $i % 2 == 0 ? '1' : '2';
                    echo "<tr class=\"data{$id}\">\n";
                    foreach ($row as $k => $v) {
                        echo "<td style=\"white-space:nowrap;\">", $misc->printVal($v, pg_fieldtype($rs, $k), array('null' => true)), "</td>";
                    }
                    echo "</tr>\n";
                    $row = pg_fetch_row($rs);
                    $i++;
                }
                echo "</table><br/>\n";
                echo $i, " {$lang['strrows']}</p>\n";
                break;
            case PGSQL_COMMAND_OK:
                // If we have the command completion tag
                if (version_compare(phpversion(), '4.3', '>=')) {
                    echo htmlspecialchars(pg_result_status($rs, PGSQL_STATUS_STRING)), "<br/>\n";
                } elseif ($data->conn->Affected_Rows() > 0) {
                    echo $data->conn->Affected_Rows(), " {$lang['strrowsaff']}<br/>\n";
                }
                // Otherwise output nothing...
                break;
            case PGSQL_EMPTY_QUERY:
                break;
            default:
                break;
        }
    }
}
开发者ID:yxwzaxns,项目名称:DaoCloud_phpPgAdmin,代码行数:51,代码来源:sql.php

示例7: query

 function query($sql)
 {
     @pg_send_query($this->link_id, $sql);
     $this->query_result = @pg_get_result($this->link_id);
     if (pg_result_status($this->query_result) != PGSQL_FATAL_ERROR) {
         ++$this->num_queries;
         //$this->last_query_text[$this->query_result] = $sql;
         return $this->query_result;
     } else {
         if ($this->in_transaction) {
             @pg_query($this->link_id, "ROLLBACK");
         }
         --$this->in_transaction;
         die(error(pg_result_error($this->query_result)));
         return false;
     }
 }
开发者ID:Refuge89,项目名称:World-of-Warcraft-Trinity-Core-MaNGOS,代码行数:17,代码来源:pgsql.php

示例8: executeScript


//.........这里部分代码省略.........
                                     if (substr($line, $i, 2) == '--') {
                                         $line = substr($line, 0, $i);
                                         /* remove comment */
                                         break;
                                     } else {
                                         if (substr($line, $i, 1) == '(') {
                                             $paren_level++;
                                         } else {
                                             if (substr($line, $i, 1) == ')' && $paren_level > 0) {
                                                 $paren_level--;
                                             } else {
                                                 if (substr($line, $i, 1) == ';' && !$bslash_count && !$paren_level) {
                                                     $subline = substr(substr($line, 0, $i), $query_start);
                                                     /* is there anything else on the line? */
                                                     if (strspn($subline, " \t\n\r") != strlen($subline)) {
                                                         /*
                                                          * insert a cosmetic newline, if this is not the first
                                                          * line in the buffer
                                                          */
                                                         if (strlen($query_buf) > 0) {
                                                             $query_buf .= "\n";
                                                         }
                                                         /* append the line to the query buffer */
                                                         $query_buf .= $subline;
                                                         $query_buf .= ';';
                                                         // Execute the query. PHP cannot execute
                                                         // empty queries, unlike libpq
                                                         $res = @pg_query($conn, $query_buf);
                                                         // Call the callback function for display
                                                         if ($callback !== null) {
                                                             $callback($query_buf, $res, $lineno);
                                                         }
                                                         // Check for COPY request
                                                         if (pg_result_status($res) == 4) {
                                                             // 4 == PGSQL_COPY_FROM
                                                             while (!feof($fd)) {
                                                                 $copy = fgets($fd, 32768);
                                                                 $lineno++;
                                                                 pg_put_line($conn, $copy);
                                                                 if ($copy == "\\.\n" || $copy == "\\.\r\n") {
                                                                     pg_end_copy($conn);
                                                                     break;
                                                                 }
                                                             }
                                                         }
                                                     }
                                                     $query_buf = null;
                                                     $query_start = $i + $thislen;
                                                 } else {
                                                     if (preg_match('/^[_[:alpha:]]$/', substr($line, $i, 1))) {
                                                         $sub = substr($line, $i, $thislen);
                                                         while (preg_match('/^[\\$_A-Za-z0-9]$/', $sub)) {
                                                             /* keep going while we still have identifier chars */
                                                             $this->advance_1($i, $prevlen, $thislen);
                                                             $sub = substr($line, $i, $thislen);
                                                         }
                                                         // Since we're now over the next character to be examined, it is necessary
                                                         // to move back one space.
                                                         $i -= $prevlen;
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
开发者ID:phppgadmin,项目名称:phppgadmin,代码行数:67,代码来源:Postgres.php

示例9: executeParams

 /**
  * Executes a given query with the ability to pass parameters separately
  *
  * @param string $sql         Query
  * @param array  $params      Parameters
  * @param array  $inputTypes  Parameter types
  * @param array  $outputTypes Result types to pass to ResultSet
  * @return bool|ResultSet|int
  * @throws exceptions\InvalidQueryException
  */
 public function executeParams($sql, array $params, array $inputTypes = array(), array $outputTypes = array())
 {
     if (!$this->isConnected()) {
         $this->connect();
     }
     $stringParams = array();
     foreach ($params as $key => $value) {
         if (isset($inputTypes[$key])) {
             $stringParams[$key] = $this->getTypeConverter($inputTypes[$key])->output($value);
         } else {
             $stringParams[$key] = $this->guessOutputFormat($value);
         }
     }
     $result = @pg_query_params($this->getResource(), $sql, $stringParams);
     if (false === $result) {
         throw new exceptions\InvalidQueryException(pg_last_error($this->getResource()));
     }
     switch (pg_result_status($result)) {
         case PGSQL_COMMAND_OK:
             $rows = pg_affected_rows($result);
             pg_free_result($result);
             return $rows;
         case PGSQL_COPY_IN:
         case PGSQL_COPY_OUT:
             pg_free_result($result);
             return true;
         case PGSQL_TUPLES_OK:
         default:
             return new ResultSet($result, $this->getTypeConverterFactory(), $outputTypes);
     }
 }
开发者ID:sad-spirit,项目名称:pg-wrapper,代码行数:41,代码来源:Connection.php

示例10: Close

 function Close()
 {
     if (version_compare(phpversion(), "4.2.0", "ge") > 0) {
         if (!$this->oid) {
             echo "{$this->error}<br>\n";
         } else {
             $this->result = pg_result_status($this->result);
             $this->error = pg_lo_close($this->oid);
         }
     }
 }
开发者ID:rmittalsfdc,项目名称:Search,代码行数:11,代码来源:postgredb.php

示例11: 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

示例12: _pg_query

 private function _pg_query($aArguments = array(), $aOKStatuses = array(PGSQL_TUPLES_OK))
 {
     if (is_scalar($aArguments)) {
         $aArguments = array($aArguments);
     }
     $iLevel = error_reporting();
     // to suppress E_WARNING that can happen
     error_reporting(0);
     $rQueryResult = pg_query($this->rConnection, $this->process($aArguments));
     $this->iLastResult = pg_result_status($rQueryResult);
     error_reporting($iLevel);
     if (!$this->isResultOK($aOKStatuses)) {
         if ($aArguments == array('ROLLBACK;')) {
             // first false forces throwException to use pg_last_error
             // second false prevents recursion:
             //      throwException -> say rollback -> unable to say rollback (e.g. server has gone) ->
             //      --> throwException -> say rollback -> unable to say rollback --> ...
             $this->throwException(false, false);
         } else {
             $this->throwException();
         }
     }
     $this->iAffectedRowsCount = (int) pg_affected_rows($rQueryResult);
     $this->iRows = (int) pg_num_rows($rQueryResult);
     return $rQueryResult;
 }
开发者ID:denismilovanov,项目名称:libpostgres,代码行数:26,代码来源:LibPostgresDriver.php

示例13: getQueryResult

 /**
  * getQueryResult
  *
  * Get an asynchronous query result.
  * The only reason for the SQL query to be passed as parameter is to throw
  * a meaningful exception when an error is raised.
  * Since it is possible to send several queries at a time, This method can
  * return an array of ResultHandler.
  *
  * @access protected
  * @param  string (default null)
  * @throws ConnectionException if no response are available.
  * @throws SqlException if the result is an error.
  * @return ResultHandler|array
  */
 protected function getQueryResult($sql = null)
 {
     $results = [];
     while ($result = pg_get_result($this->getHandler())) {
         $status = pg_result_status($result, \PGSQL_STATUS_LONG);
         if ($status !== \PGSQL_COMMAND_OK && $status !== \PGSQL_TUPLES_OK) {
             throw new SqlException($result, $sql);
         }
         $results[] = new ResultHandler($result);
     }
     if (count($results) === 0) {
         throw new ConnectionException(sprintf("There are no waiting results in connection.\nQuery = '%s'.", $sql));
     }
     return count($results) === 1 ? $results[0] : $results;
 }
开发者ID:SebLours,项目名称:Foundation,代码行数:30,代码来源:Connection.php

示例14: hasResult

 function hasResult($stack = 0)
 {
     return @pg_result_status($this->result[$stack]) == PGSQL_TUPLES_OK;
 }
开发者ID:onyxnz,项目名称:quartzpos,代码行数:4,代码来源:pgsql.php

示例15: run_command

 protected function run_command($command)
 {
     $result = pg_query($this->conn, $command);
     if ($result === false) {
         return false;
     }
     return pg_result_status($result) === PGSQL_COMMAND_OK;
 }
开发者ID:xpd1437,项目名称:swap,代码行数:8,代码来源:pgsql_rdb.php


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