2010-03-28 22:10:10 +00:00
|
|
|
<?xml version="1.0" encoding="utf-8"?>
|
2009-07-11 08:37:21 +00:00
|
|
|
<!-- $Revision$ -->
|
2002-04-15 00:12:54 +00:00
|
|
|
<!-- splitted from ./en/functions/pgsql.xml, last change in rev 1.2 -->
|
2007-06-20 22:25:43 +00:00
|
|
|
<refentry xml:id="function.pg-field-name" xmlns="http://docbook.org/ns/docbook">
|
2005-03-08 00:06:33 +00:00
|
|
|
<refnamediv>
|
|
|
|
<refname>pg_field_name</refname>
|
|
|
|
<refpurpose>Returns the name of a field</refpurpose>
|
|
|
|
</refnamediv>
|
2005-03-11 16:03:26 +00:00
|
|
|
|
|
|
|
<refsect1 role="description">
|
|
|
|
&reftitle.description;
|
|
|
|
<methodsynopsis>
|
|
|
|
<type>string</type><methodname>pg_field_name</methodname>
|
|
|
|
<methodparam><type>resource</type><parameter>result</parameter></methodparam>
|
|
|
|
<methodparam><type>int</type><parameter>field_number</parameter></methodparam>
|
|
|
|
</methodsynopsis>
|
2005-03-08 00:06:33 +00:00
|
|
|
<para>
|
|
|
|
<function>pg_field_name</function> returns the name of the field
|
|
|
|
occupying the given <parameter>field_number</parameter> in the
|
|
|
|
given PostgreSQL <parameter>result</parameter> resource. Field
|
|
|
|
numbering starts from 0.
|
|
|
|
</para>
|
2005-03-11 16:03:26 +00:00
|
|
|
<note>
|
|
|
|
<para>
|
2005-04-21 09:29:36 +00:00
|
|
|
This function used to be called <function>pg_fieldname</function>.
|
2005-03-11 16:03:26 +00:00
|
|
|
</para>
|
|
|
|
</note>
|
|
|
|
</refsect1>
|
|
|
|
|
2005-04-07 11:47:32 +00:00
|
|
|
<refsect1 role="parameters">
|
|
|
|
&reftitle.parameters;
|
|
|
|
<para>
|
|
|
|
<variablelist>
|
|
|
|
<varlistentry>
|
|
|
|
<term><parameter>result</parameter></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
PostgreSQL query result resource, returned by <function>pg_query</function>,
|
|
|
|
<function>pg_query_params</function> or <function>pg_execute</function>
|
|
|
|
(among others).
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
<varlistentry>
|
|
|
|
<term><parameter>field_number</parameter></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Field number, starting from 0.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
</variablelist>
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="returnvalues">
|
|
|
|
&reftitle.returnvalues;
|
|
|
|
<para>
|
|
|
|
The field name, or &false; on error.
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
|
2005-03-11 16:03:26 +00:00
|
|
|
<refsect1 role="examples">
|
|
|
|
&reftitle.examples;
|
2005-03-08 00:06:33 +00:00
|
|
|
<para>
|
|
|
|
<example>
|
|
|
|
<title>Getting information about fields</title>
|
|
|
|
<programlisting role="php">
|
2003-07-15 22:36:03 +00:00
|
|
|
<![CDATA[
|
|
|
|
<?php
|
2005-03-08 00:06:33 +00:00
|
|
|
$dbconn = pg_connect("dbname=publisher") or die("Could not connect");
|
2003-07-15 22:36:03 +00:00
|
|
|
|
2005-03-08 00:06:33 +00:00
|
|
|
$res = pg_query($dbconn, "select * from authors where author = 'Orwell'");
|
|
|
|
$i = pg_num_fields($res);
|
|
|
|
for ($j = 0; $j < $i; $j++) {
|
|
|
|
echo "column $j\n";
|
|
|
|
$fieldname = pg_field_name($res, $j);
|
|
|
|
echo "fieldname: $fieldname\n";
|
|
|
|
echo "printed length: " . pg_field_prtlen($res, $fieldname) . " characters\n";
|
|
|
|
echo "storage length: " . pg_field_size($res, $j) . " bytes\n";
|
|
|
|
echo "field type: " . pg_field_type($res, $j) . " \n\n";
|
|
|
|
}
|
2003-07-15 22:36:03 +00:00
|
|
|
?>
|
|
|
|
]]>
|
2005-03-08 00:06:33 +00:00
|
|
|
</programlisting>
|
2005-03-11 16:03:26 +00:00
|
|
|
&example.outputs;
|
2005-03-08 00:06:33 +00:00
|
|
|
<screen>
|
2003-07-15 22:36:03 +00:00
|
|
|
<![CDATA[
|
|
|
|
column 0
|
|
|
|
fieldname: author
|
|
|
|
printed length: 6 characters
|
|
|
|
storage length: -1 bytes
|
|
|
|
field type: varchar
|
|
|
|
|
|
|
|
column 1
|
|
|
|
fieldname: year
|
|
|
|
printed length: 4 characters
|
|
|
|
storage length: 2 bytes
|
|
|
|
field type: int2
|
|
|
|
|
|
|
|
column 2
|
|
|
|
fieldname: title
|
|
|
|
printed length: 24 characters
|
|
|
|
storage length: -1 bytes
|
|
|
|
field type: varchar
|
|
|
|
]]>
|
2005-03-08 00:06:33 +00:00
|
|
|
</screen>
|
|
|
|
</example>
|
|
|
|
</para>
|
2005-03-11 16:03:26 +00:00
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="seealso">
|
|
|
|
&reftitle.seealso;
|
2005-03-08 00:06:33 +00:00
|
|
|
<para>
|
2005-03-11 16:03:26 +00:00
|
|
|
<simplelist>
|
|
|
|
<member><function>pg_field_num</function></member>
|
|
|
|
</simplelist>
|
2005-03-08 00:06:33 +00:00
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
2002-04-15 00:12:54 +00:00
|
|
|
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
|
|
Local variables:
|
|
|
|
mode: sgml
|
|
|
|
sgml-omittag:t
|
|
|
|
sgml-shorttag:t
|
|
|
|
sgml-minimize-attributes:nil
|
|
|
|
sgml-always-quote-attributes:t
|
|
|
|
sgml-indent-step:1
|
|
|
|
sgml-indent-data:t
|
|
|
|
indent-tabs-mode:nil
|
|
|
|
sgml-parent-document:nil
|
2009-09-25 07:04:39 +00:00
|
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
2002-04-15 00:12:54 +00:00
|
|
|
sgml-exposed-tags:nil
|
|
|
|
sgml-local-catalogs:nil
|
|
|
|
sgml-local-ecat-files:nil
|
|
|
|
End:
|
|
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
|
|
vim: et tw=78 syn=sgml
|
|
|
|
vi: ts=1 sw=1
|
|
|
|
-->
|