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


PHP pg_num_fields函数代码示例

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


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

示例1: query_start

 function query_start($query)
 {
     // For reg expressions
     $query = trim($query);
     // Query was an insert, delete, update, replace
     if (preg_match("/^(insert|delete|update|replace)\\s+/i", $query)) {
         return false;
     }
     // Flush cached values..
     $this->flush();
     // Log how the function was called
     $this->func_call = "\$db->query_start(\"{$query}\")";
     // Keep track of the last query for debug..
     $this->last_query = $query;
     // Perform the query via std pg_query function..
     if (!($this->result = @pg_query($this->dbh, $query))) {
         $this->print_error();
         return false;
     }
     $this->num_queries++;
     // =======================================================
     // Take note of column info
     $i = 0;
     while ($i < @pg_num_fields($this->result)) {
         $this->col_info[$i]->name = pg_field_name($this->result, $i);
         $this->col_info[$i]->type = pg_field_type($this->result, $i);
         $this->col_info[$i]->size = pg_field_size($this->result, $i);
         $i++;
     }
     $this->last_result = array();
     $this->num_rows = 0;
     // If debug ALL queries
     $this->trace || $this->debug_all ? $this->debug() : null;
     return true;
 }
开发者ID:aim-web-projects,项目名称:kobe-chuoh,代码行数:35,代码来源:mtdb_postgres.php

示例2: postgis_query

function postgis_query($string, $pgc = NULL)
{
    $pgct = $pgc;
    if ($pgc == NULL) {
        $pgct = postgis_connect();
    }
    @($result = pg_query($pgct, $string));
    if ($pgc == NULL) {
        pg_close($pgct);
    }
    $retval = array();
    if (!$result) {
        return $retval;
    }
    $arow = array();
    for ($i = 0; $i < pg_num_fields($result); $i++) {
        $arow[pg_field_name($result, $i)] = pg_field_type($result, $i);
    }
    $retval[0] = $arow;
    $ctr = 1;
    while ($row = pg_fetch_row($result)) {
        $arow = array();
        for ($i = 0; $i < count($row); $i++) {
            $arow[pg_field_name($result, $i)] = $row[$i];
        }
        $retval[$ctr] = $arow;
        $ctr++;
    }
    pg_free_result($result);
    return $retval;
}
开发者ID:rvaidya,项目名称:FlexGIS,代码行数:31,代码来源:helper.php

示例3: printUserLog

function printUserLog()
{
    //db connection
    $conn = pg_connect(HOST . " " . DBNAME . " " . USERNAME . " " . PASSWORD) or die('Could not connect: ' . pg_last_error());
    //query the database
    $result = pg_prepare($conn, "getLog", "SELECT * FROM lab8.log\n\t\t\tWHERE username LIKE \$1") or die("getLog prepare fail: " . pg_last_error());
    $result = pg_execute($conn, "getLog", array($_SESSION['user'])) or die("getLog execute fail: " . pg_last_error());
    //Printing results in HTML
    echo "<br>There where <em>" . pg_num_rows($result) . "</em> rows returned<br><br>\n";
    echo "<table class='tablestuff' border='1'>";
    //account for added form row
    echo "<tr>";
    //checking the number of fields return to populate header
    $numFields = pg_num_fields($result);
    //populating the header
    for ($i = 0; $i < $numFields; $i++) {
        $fieldName = pg_field_name($result, $i);
        echo "<th width=\"135\">" . $fieldName . "</th>\n";
    }
    echo "</tr>";
    //populating table with the results
    while ($line = pg_fetch_array($result, null, PGSQL_ASSOC)) {
        echo "\t<tr>\n";
        foreach ($line as $col_value) {
            echo "\t\t<td>{$col_value}</td>\n";
        }
        echo "\t</tr>\n";
    }
    echo "</table>\n";
    // Free resultset
    pg_free_result($result);
    //close connection
    pg_close($conn);
}
开发者ID:samkreter,项目名称:PHP-Postgresql-work,代码行数:34,代码来源:helperFunctions.php

示例4: exportWithQuery

 function exportWithQuery($qry, $file_name, $type)
 {
     $tmprst = pg_query($qry);
     $header = '<center><table width="100%">';
     $num_field = pg_num_fields($tmprst);
     while ($row = pg_fetch_array($tmprst)) {
         $body .= "<tr>";
         for ($i = 0; $i < $num_field; $i++) {
             $body .= "<td>" . $row[$i] . "</td>";
         }
         $body .= "</tr>";
     }
     if ($type == 'xls') {
         $this->setHeaderXLS($file_name);
     } else {
         if ($type == 'doc') {
             $this->setHeaderDoc($file_name);
         } else {
             if ($type == 'csv') {
                 $this->setHeaderCSV($file_name);
             }
         }
     }
     echo $header . $body . "</table>";
 }
开发者ID:suzinkyaw,项目名称:jenkins,代码行数:25,代码来源:ExportPHP.class.php

示例5: PG_QueryStart

function PG_QueryStart($SQL, &$aFields, &$link, &$Errors)
{
    $gMyHOST = "127.0.0.1";
    $gMyDB = "osm";
    $gMyUSER = "osm";
    $gMyPASS = "insertPassword";
    $Errors = "";
    $result = false;
    $conn_string = "host={$gMyHOST} port=5432 dbname={$gMyDB} user={$gMyUSER} password={$gMyPASS}";
    $link = pg_connect($conn_string);
    if ($link === false) {
        $Errors .= "Impossibile connettersi a '{$gMyHOST}' come '{$gMyUSER}'";
    } else {
        $result = pg_query($SQL);
        if ($result === false) {
            $Errors .= ($Errors[0] ? "" : "<br>") . "Errore durante la query '{$SQL}': " . pg_last_error();
        } else {
            $nFields = pg_num_fields($result);
            for ($ind = 0; $ind < $nFields; $ind++) {
                $aFields[$ind] = array(pg_field_name($result, $ind), pg_field_type($result, $ind));
            }
        }
    }
    return $result;
}
开发者ID:napo,项目名称:osm-italy-stats,代码行数:25,代码来源:DB_Func.php

示例6: __construct

 /**
  * Constructor.
  *
  * @param resource    $resource SQL result resource.
  * @param TypeConverterFactory $factory
  * @param array       $types    Types information, used to convert output values (overrides auto-generated types).
  * @throws exceptions\InvalidArgumentException
  */
 public function __construct($resource, TypeConverterFactory $factory, array $types = array())
 {
     if (!is_resource($resource) || 'pgsql result' !== get_resource_type($resource)) {
         throw new exceptions\InvalidArgumentException(sprintf("%s requires a query result resource, '%s' given", __CLASS__, is_resource($resource) ? 'resource(' . get_resource_type($resource) . ')' : gettype($resource)));
     }
     $this->_resource = $resource;
     $this->_converterFactory = $factory;
     $this->_numRows = pg_num_rows($this->_resource);
     $this->_numFields = pg_num_fields($this->_resource);
     $oids = array();
     for ($i = 0; $i < $this->_numFields; $i++) {
         $this->_namesHash[pg_field_name($this->_resource, $i)] = $i;
         $oids[$i] = pg_field_type_oid($this->_resource, $i);
     }
     // first set the explicitly given types...
     foreach ($types as $index => $type) {
         $this->setType($index, $type);
     }
     // ...then use type factory to create default converters
     for ($i = 0; $i < $this->_numFields; $i++) {
         if (!isset($this->_converters[$i])) {
             $this->_converters[$i] = $this->_converterFactory->getConverter($oids[$i]);
         }
     }
 }
开发者ID:sad-spirit,项目名称:pg-wrapper,代码行数:33,代码来源:ResultSet.php

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

示例8: columnCount

 public function columnCount()
 {
     if ($this->_result) {
         return pg_num_fields($this->_result);
     }
     return 0;
 }
开发者ID:PHPcomaptibility,项目名称:PHPPDO,代码行数:7,代码来源:pgsql_statement.php

示例9: columnCount

 /**
  * Public method:
  *	Checks if query was valid and returns how may fields returns
  *       	this->columnCount( void ):Void
  */
 function columnCount()
 {
     $result = 0;
     if (!is_null($this->__result)) {
         $result = pg_num_fields($this->__result);
     }
     return $result;
 }
开发者ID:D4rk4,项目名称:Kusaba-z,代码行数:13,代码来源:PDOStatement_pgsql.class.php

示例10: getColumnCount

function getColumnCount($table)
{
    global $connection;
    $connection;
    $result = pg_query($connection, "SELECT * FROM {$table}");
    $num = pg_num_fields($result);
    return $num;
    pg_close($connection);
}
开发者ID:JacekKarwas,项目名称:smutek,代码行数:9,代码来源:logic.php

示例11: numCols

 function numCols()
 {
     if (IFPG) {
         return pg_num_fields($this->result);
     }
     if (IFMY) {
         return mysql_num_fields($this->result);
     }
 }
开发者ID:BackupTheBerlios,项目名称:igoan-svn,代码行数:9,代码来源:Result.class.php

示例12: getTitulos

 function getTitulos($result)
 {
     $num = pg_num_fields($result);
     $titulos = array();
     for ($i = 0; $i < $num; $i++) {
         $titulos[$i] = pg_field_name($result, $i);
     }
     return $titulos;
 }
开发者ID:blacburn,项目名称:VirtusFinal,代码行数:9,代码来源:dao.php

示例13: __construct

 /**
  * Constructor
  *
  * @param   resource handle
  */
 public function __construct($result, TimeZone $tz = NULL)
 {
     $fields = array();
     if (is_resource($result)) {
         for ($i = 0, $num = pg_num_fields($result); $i < $num; $i++) {
             $fields[pg_field_name($result, $i)] = pg_field_type($result, $i);
         }
     }
     parent::__construct($result, $fields, $tz);
 }
开发者ID:melogamepay,项目名称:xp-framework,代码行数:15,代码来源:PostgreSQLResultSet.class.php

示例14: getTypes

 public function getTypes()
 {
     $types = [];
     $count = pg_num_fields($this->result);
     for ($i = 0; $i < $count; $i++) {
         $nativeType = pg_field_type($this->result, $i);
         $types[pg_field_name($this->result, $i)] = [0 => isset(self::$types[$nativeType]) ? self::$types[$nativeType] : self::TYPE_AS_IS, 1 => $nativeType];
     }
     return $types;
 }
开发者ID:nextras,项目名称:dbal,代码行数:10,代码来源:PgsqlResultAdapter.php

示例15: _performGetBlobFieldNames

 function _performGetBlobFieldNames($result)
 {
     $blobFields = array();
     for ($i = pg_num_fields($result) - 1; $i >= 0; $i--) {
         $type = pg_field_type($result, $i);
         if (strpos($type, "BLOB") !== false) {
             $blobFields[] = pg_field_name($result, $i);
         }
     }
     return $blobFields;
 }
开发者ID:space77,项目名称:mwfv3_sp,代码行数:11,代码来源:Postgresql.php


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