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


PHP pg_fieldname函数代码示例

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


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

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

示例2: vty_field_name

function vty_field_name($list,$i){
        switch($this->vtAdi){
        case 'mysql': return mysql_field_name($list,$i); break;
        case 'odbc': return odbc_field_name($list,$i); break;
        case 'mssql': return mssql_field_name($list,$i); break;
        case 'postgresql': return pg_fieldname($list,$i); break;
        }
}
开发者ID:awddesign,项目名称:vty,代码行数:8,代码来源:vty.php

示例3: tableInfo

 /**
  * Returns information about a table or a result set.
  *
  * NOTE: only supports 'table' and 'flags' if <var>$result</var>
  * is a table name.
  *
  * @param object|string  $result  DB_result object from a query or a
  *                                string containing the name of a table
  * @param int            $mode    a valid tableInfo mode
  * @return array  an associative array with the information requested
  *                or an error object if something is wrong
  * @access public
  * @internal
  * @see DB_common::tableInfo()
  */
 function tableInfo($result, $mode = null)
 {
     if (isset($result->result)) {
         /*
          * Probably received a result object.
          * Extract the result resource identifier.
          */
         $id = $result->result;
         $got_string = false;
     } elseif (is_string($result)) {
         /*
          * Probably received a table name.
          * Create a result resource identifier.
          */
         $id = @pg_exec($this->connection, "SELECT * FROM {$result} LIMIT 0");
         $got_string = true;
     } else {
         /*
          * Probably received a result resource identifier.
          * Copy it.
          * Deprecated.  Here for compatibility only.
          */
         $id = $result;
         $got_string = false;
     }
     if (!is_resource($id)) {
         return $this->pgsqlRaiseError(DB_ERROR_NEED_MORE_DATA);
     }
     if ($this->options['portability'] & DB_PORTABILITY_LOWERCASE) {
         $case_func = 'strtolower';
     } else {
         $case_func = 'strval';
     }
     $count = @pg_numfields($id);
     // made this IF due to performance (one if is faster than $count if's)
     if (!$mode) {
         for ($i = 0; $i < $count; $i++) {
             $res[$i]['table'] = $got_string ? $case_func($result) : '';
             $res[$i]['name'] = $case_func(@pg_fieldname($id, $i));
             $res[$i]['type'] = @pg_fieldtype($id, $i);
             $res[$i]['len'] = @pg_fieldsize($id, $i);
             $res[$i]['flags'] = $got_string ? $this->_pgFieldflags($id, $i, $result) : '';
         }
     } else {
         // full
         $res['num_fields'] = $count;
         for ($i = 0; $i < $count; $i++) {
             $res[$i]['table'] = $got_string ? $case_func($result) : '';
             $res[$i]['name'] = $case_func(@pg_fieldname($id, $i));
             $res[$i]['type'] = @pg_fieldtype($id, $i);
             $res[$i]['len'] = @pg_fieldsize($id, $i);
             $res[$i]['flags'] = $got_string ? $this->_pgFieldFlags($id, $i, $result) : '';
             if ($mode & DB_TABLEINFO_ORDER) {
                 $res['order'][$res[$i]['name']] = $i;
             }
             if ($mode & DB_TABLEINFO_ORDERTABLE) {
                 $res['ordertable'][$res[$i]['table']][$res[$i]['name']] = $i;
             }
         }
     }
     // free the result only if we were called on a table
     if ($got_string) {
         @pg_freeresult($id);
     }
     return $res;
 }
开发者ID:nanoprime,项目名称:sureinvoice,代码行数:81,代码来源:pgsql.php

示例4: _pgFieldFlags

 /**
  * Get a column's flags
  *
  * Supports "not_null", "default_value", "primary_key", "unique_key"
  * and "multiple_key".  The default value is passed through
  * rawurlencode() in case there are spaces in it.
  *
  * @param int $resource   the PostgreSQL result identifier
  * @param int $num_field  the field number
  *
  * @return string  the flags
  *
  * @access private
  */
 function _pgFieldFlags($resource, $num_field, $table_name)
 {
     $field_name = @pg_fieldname($resource, $num_field);
     // Check if there's a schema in $table_name and update things
     // accordingly.
     $from = 'pg_attribute f, pg_class tab, pg_type typ';
     if (strpos($table_name, '.') !== false) {
         $from .= ', pg_namespace nsp';
         list($schema, $table) = explode('.', $table_name);
         $tableWhere = "tab.relname = '{$table}' AND tab.relnamespace = nsp.oid AND nsp.nspname = '{$schema}'";
     } else {
         $tableWhere = "tab.relname = '{$table_name}'";
     }
     $result = @pg_exec($this->connection, "SELECT f.attnotnull, f.atthasdef\n                                FROM {$from}\n                                WHERE tab.relname = typ.typname\n                                AND typ.typrelid = f.attrelid\n                                AND f.attname = '{$field_name}'\n                                AND {$tableWhere}");
     if (@pg_numrows($result) > 0) {
         $row = @pg_fetch_row($result, 0);
         $flags = $row[0] == 't' ? 'not_null ' : '';
         if ($row[1] == 't') {
             $result = @pg_exec($this->connection, "SELECT a.adsrc\n                                    FROM {$from}, pg_attrdef a\n                                    WHERE tab.relname = typ.typname AND typ.typrelid = f.attrelid\n                                    AND f.attrelid = a.adrelid AND f.attname = '{$field_name}'\n                                    AND {$tableWhere} AND f.attnum = a.adnum");
             $row = @pg_fetch_row($result, 0);
             $num = preg_replace("/'(.*)'::\\w+/", "\\1", $row[0]);
             $flags .= 'default_' . rawurlencode($num) . ' ';
         }
     } else {
         $flags = '';
     }
     $result = @pg_exec($this->connection, "SELECT i.indisunique, i.indisprimary, i.indkey\n                                FROM {$from}, pg_index i\n                                WHERE tab.relname = typ.typname\n                                AND typ.typrelid = f.attrelid\n                                AND f.attrelid = i.indrelid\n                                AND f.attname = '{$field_name}'\n                                AND {$tableWhere}");
     $count = @pg_numrows($result);
     for ($i = 0; $i < $count; $i++) {
         $row = @pg_fetch_row($result, $i);
         $keys = explode(' ', $row[2]);
         if (in_array($num_field + 1, $keys)) {
             $flags .= $row[0] == 't' && $row[1] == 'f' ? 'unique_key ' : '';
             $flags .= $row[1] == 't' ? 'primary_key ' : '';
             if (count($keys) > 1) {
                 $flags .= 'multiple_key ';
             }
         }
     }
     return trim($flags);
 }
开发者ID:Kraiany,项目名称:kraiany_site_docker,代码行数:55,代码来源:pgsql.php

示例5: _pgFieldFlags

 /**
  * Get a column's flags
  *
  * Supports "not_null", "default_value", "primary_key", "unique_key"
  * and "multiple_key".  The default value is passed through
  * rawurlencode() in case there are spaces in it.
  *
  * @param int $resource   the PostgreSQL result identifier
  * @param int $num_field  the field number
  *
  * @return string  the flags
  *
  * @access private
  */
 function _pgFieldFlags($resource, $num_field, $table_name)
 {
     $field_name = @pg_fieldname($resource, $num_field);
     $result = @pg_exec($this->connection, "SELECT f.attnotnull, f.atthasdef\n                                FROM pg_attribute f, pg_class tab, pg_type typ\n                                WHERE tab.relname = typ.typname\n                                AND typ.typrelid = f.attrelid\n                                AND f.attname = '{$field_name}'\n                                AND tab.relname = '{$table_name}'");
     if (@pg_numrows($result) > 0) {
         $row = @pg_fetch_row($result, 0);
         $flags = $row[0] == 't' ? 'not_null ' : '';
         if ($row[1] == 't') {
             $result = @pg_exec($this->connection, "SELECT a.adsrc\n                                    FROM pg_attribute f, pg_class tab, pg_type typ, pg_attrdef a\n                                    WHERE tab.relname = typ.typname AND typ.typrelid = f.attrelid\n                                    AND f.attrelid = a.adrelid AND f.attname = '{$field_name}'\n                                    AND tab.relname = '{$table_name}' AND f.attnum = a.adnum");
             $row = @pg_fetch_row($result, 0);
             $num = preg_replace("/'(.*)'::\\w+/", "\\1", $row[0]);
             $flags .= 'default_' . rawurlencode($num) . ' ';
         }
     } else {
         $flags = '';
     }
     $result = @pg_exec($this->connection, "SELECT i.indisunique, i.indisprimary, i.indkey\n                                FROM pg_attribute f, pg_class tab, pg_type typ, pg_index i\n                                WHERE tab.relname = typ.typname\n                                AND typ.typrelid = f.attrelid\n                                AND f.attrelid = i.indrelid\n                                AND f.attname = '{$field_name}'\n                                AND tab.relname = '{$table_name}'");
     $count = @pg_numrows($result);
     for ($i = 0; $i < $count; $i++) {
         $row = @pg_fetch_row($result, $i);
         $keys = explode(' ', $row[2]);
         if (in_array($num_field + 1, $keys)) {
             $flags .= $row[0] == 't' && $row[1] == 'f' ? 'unique_key ' : '';
             $flags .= $row[1] == 't' ? 'primary_key ' : '';
             if (count($keys) > 1) {
                 $flags .= 'multiple_key ';
             }
         }
     }
     return trim($flags);
 }
开发者ID:ballistiq,项目名称:revive-adserver,代码行数:45,代码来源:pgsql.php

示例6: GetColumnNames

 function GetColumnNames($result, &$column_names)
 {
     if (!isset($this->highest_fetched_row[$result])) {
         return $this->SetError("Get Column Names", "it was specified an inexisting result set");
     }
     if (!isset($this->columns[$result])) {
         $this->columns[$result] = array();
         $columns = pg_numfields($result);
         for ($column = 0; $column < $columns; $column++) {
             $this->columns[$result][strtolower(pg_fieldname($result, $column))] = $column;
         }
     }
     $column_names = $this->columns[$result];
     return 1;
 }
开发者ID:wycus,项目名称:darmedic,代码行数:15,代码来源:metabase_pgsql.php

示例7: sec_showresult

function sec_showresult($result)
{
    $n = pg_numfields($result);
    echo '<table border=1 width="100%">';
    echo '<tr>';
    for ($j = 0; $j < $n; $j++) {
        $a = pg_fieldname($result, $j);
        echo "<td>{$a}</td>";
    }
    echo '</tr>';
    $rows = pg_numrows($result);
    for ($i = 0; $i < $rows; $i++) {
        echo '<tr>';
        $row = pg_fetch_row($result, $i);
        for ($j = 0; $j < $n; $j++) {
            echo "<td>{$row[$j]}</td>";
        }
        echo '</tr>';
    }
    echo '</table>';
    if ($rows == 0) {
        echo '<p><b>No matches found</b>';
    } else {
        echo "<p>{$rows} items found";
    }
}
开发者ID:helio-vo,项目名称:helio,代码行数:26,代码来源:hec_global.php

示例8: db_fieldname

/**
 *
 *  Returns the number of rows changed in the last query
 *
 *  @param qhandle - query result set handle
 *  @param fnumber - column number
 *
 */
function db_fieldname($lhandle, $fnumber)
{
    return @pg_fieldname($lhandle, $fnumber);
}
开发者ID:BackupTheBerlios,项目名称:berlios,代码行数:12,代码来源:database-pgsql.php

示例9: GetColumnName

 function GetColumnName($col)
 {
     return pg_fieldname($this->result, $col - 1);
 }
开发者ID:fraancisneiluiz,项目名称:ciaweb,代码行数:4,代码来源:common.php

示例10: FieldName

 function FieldName($result, $offset)
 {
     switch ($this->dbType) {
         case "mssql":
             $r = mssql_field_name($result, $offset);
             break;
         case "mysql":
             $r = mysql_field_name($result, $offset);
             break;
         case "pg":
             $r = pg_fieldname($result, $offset);
             break;
         default:
             $r = False;
             break;
     }
     return $r;
 }
开发者ID:sgh1986915,项目名称:php-crm,代码行数:18,代码来源:clsDatabase.php

示例11: pg_exec

        echo $strField;
        ?>
</th>
		<th><?php 
        echo $strType;
        ?>
</th>
		<th><?php 
        echo $strValue;
        ?>
</th>
		</tr>
		<?php 
        $result = pg_exec($link, pre_query($sql_get_fields));
        for ($i = 0; $i < pg_numfields($result); $i++) {
            $field = pg_fieldname($result, $i);
            $type = pg_fieldtype($result, $i);
            $len = pg_fieldsize($result, $i);
            if ($len < 1) {
                $len_disp = "var";
                $len = 50;
            } else {
                $len_disp = $len;
            }
            $bgcolor = $cfgBgcolorOne;
            $i % 2 ? 0 : ($bgcolor = $cfgBgcolorTwo);
            echo "<tr bgcolor=" . $bgcolor . ">";
            echo "<td>{$field}</td>";
            echo "<td>{$type} ({$len_disp})</td>";
            if ($type == "bool") {
                echo "<td><select name=fields[]><option value=\"t\">True<option value=\"f\">False</select></td>";
开发者ID:CMMCO,项目名称:Intranet,代码行数:31,代码来源:tbl_select.php

示例12: _pgFieldFlags

 /**
  * Flags of a Field
  *
  * @param int $resource PostgreSQL result identifier
  * @param int $num_field the field number
  * @return string The flags of the field ('not_null', 'default_xx', 'primary_key',
  *                 'unique' and 'multiple_key' are supported)
  * @access private
  **/
 function _pgFieldFlags($resource, $num_field, $table_name)
 {
     $field_name = @pg_fieldname($resource, $num_field);
     $result = pg_exec($this->connection, "SELECT f.attnotnull, f.atthasdef\r\n            FROM pg_attribute f, pg_class tab, pg_type typ\r\n            WHERE tab.relname = typ.typname\r\n            AND typ.typrelid = f.attrelid\r\n            AND f.attname = '{$field_name}'\r\n            AND tab.relname = '{$table_name}'");
     if (@pg_numrows($result) > 0) {
         $row = @pg_fetch_row($result, 0);
         $flags = $row[0] == 't' ? 'not_null ' : '';
         if ($row[1] == 't') {
             $result = @pg_exec($this->connection, "SELECT a.adsrc\r\n                    FROM pg_attribute f, pg_class tab, pg_type typ, pg_attrdef a\r\n                    WHERE tab.relname = typ.typname AND typ.typrelid = f.attrelid\r\n                    AND f.attrelid = a.adrelid AND f.attname = '{$field_name}'\r\n                    AND tab.relname = '{$table_name}'");
             $row = @pg_fetch_row($result, 0);
             $num = str_replace('\'', '', $row[0]);
             $flags .= "default_{$num} ";
         }
     }
     $result = @pg_exec($this->connection, "SELECT i.indisunique, i.indisprimary, i.indkey\r\n            FROM pg_attribute f, pg_class tab, pg_type typ, pg_index i\r\n            WHERE tab.relname = typ.typname\r\n            AND typ.typrelid = f.attrelid\r\n            AND f.attrelid = i.indrelid\r\n            AND f.attname = '{$field_name}'\r\n            AND tab.relname = '{$table_name}'");
     $count = @pg_numrows($result);
     for ($i = 0; $i < $count; $i++) {
         $row = @pg_fetch_row($result, $i);
         $keys = explode(' ', $row[2]);
         if (in_array($num_field + 1, $keys)) {
             $flags .= $row[0] == 't' ? 'unique ' : '';
             $flags .= $row[1] == 't' ? 'primary ' : '';
             if (count($keys) > 1) {
                 $flags .= 'multiple_key ';
             }
         }
     }
     return trim($flags);
 }
开发者ID:GeekyNinja,项目名称:LifesavingCAD,代码行数:38,代码来源:pgsql.php

示例13: GetFieldName

 function GetFieldName($fieldIndex)
 {
     if ($this->res) {
         return pg_fieldname($this->res, $fieldIndex);
     }
     return '';
 }
开发者ID:ljvblfz,项目名称:mysoftwarebrasil,代码行数:7,代码来源:class.DCL_DB_pgsql.inc.php

示例14: status

 }
 // get the fields
 status("querying for data... ");
 $flds_rslt = pg_exec("SELECT * FROM \"{$schema}\".{$tbl_name}");
 status("done\n");
 $create_fields = array();
 // reset it
 $insert_fields = array();
 // reset it
 $sequences = array();
 status("creating create query...\n");
 for ($fld_num = 0; $fld_num < pg_numfields($flds_rslt); $fld_num++) {
     $nextval = false;
     // last sequence value
     // read the fieldname
     $f_name = pg_fieldname($flds_rslt, $fld_num);
     $f_info = $fields_info[$tbl_name][$f_name];
     status("done\n");
     // if field has a default value starting with nextval, get the sequence name
     $seq_name = array();
     status("checking for sequence... ");
     // true_ids is a column for which we should not recreate a sequence, they are
     // manually created (usually used for tables sharing 1 sequence)
     if ($f_name != "true_ids" && (preg_match("/^nextval\\('(.*)\\.(.*)'::text\\)/", $f_info["default"], $seq_name) || preg_match("/^nextval\\('(.*)\\.(.*)'::regclass\\)/", $f_info["default"], $seq_name))) {
         status(" (seq) ");
         $seq_schema = $seq_name[1];
         $seq_name = $seq_name[2];
         $f_type = "serial NOT NULL PRIMARY KEY";
         // read the next val it had
         $nval_rslt = pg_exec("SELECT last_value FROM {$seq_schema}.{$seq_name}");
         if (pg_num_rows($nval_rslt) > 0) {
开发者ID:andrecoetzee,项目名称:accounting-123.com,代码行数:31,代码来源:__dump_base.php

示例15: parse_pgsql

 function parse_pgsql($file_id, $result_name)
 {
     global ${$result_name};
     $loop_code = '';
     $start_pos = strpos(strtolower($this->files[$file_id]), '<loop name="' . $result_name . '">') + strlen('<loop name="' . $result_name . '">');
     $end_pos = strpos(strtolower($this->files[$file_id]), '</loop name="' . $result_name . '">');
     $loop_code = substr($this->files[$file_id], $start_pos, $end_pos - $start_pos);
     $start_tag = substr($this->files[$file_id], strpos(strtolower($this->files[$file_id]), '<loop name="' . $result_name . '">'), strlen('<loop name="' . $result_name . '">'));
     $end_tag = substr($this->files[$file_id], strpos(strtolower($this->files[$file_id]), '</loop name="' . $result_name . '">'), strlen('</loop name="' . $result_name . '">'));
     if ($loop_code != '') {
         $new_code = '';
         $field_names = array();
         for ($i = 0; $i < pg_numfields(${$result_name}); $i++) {
             $field_names[] = pg_fieldname(${$result_name}, $i);
         }
         for ($i = 0; $i < pg_getNumberRows(${$result_name}) and $row_data = pg_fetch_array(${$result_name}, $i); $i++) {
             $temp_code = $loop_code;
             for ($j = 0; $j < count($field_names); $j++) {
                 $temp_code = str_replace($this->start . $field_names[$j] . $this->end, $row_data[$field_names[$j]], $temp_code);
             }
             $new_code .= $temp_code;
         }
         $this->files[$file_id] = str_replace($start_tag . $loop_code . $end_tag, $new_code, $this->files[$file_id]);
     }
 }
开发者ID:innomatic-libs,项目名称:rhtemplatelib,代码行数:25,代码来源:RhTemplate.php


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