php-doc-en/reference/pgsql/functions/pg-field-name.xml
Mehdi Achour e8844eadb3 some more CS
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@146748 c90b9560-bf6c-de11-be94-00142212c4b1
2003-12-18 17:46:56 +00:00

99 lines
2.7 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.5 $ -->
<!-- splitted from ./en/functions/pgsql.xml, last change in rev 1.2 -->
<refentry id="function.pg-field-name">
<refnamediv>
<refname>pg_field_name</refname>
<refpurpose>Returns the name of a field</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<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>
<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>
<para>
<example>
<title>Getting informations about fields</title>
<programlisting role="php">
<![CDATA[
<?php
$dbconn = pg_connect("dbname=publisher") or die("Could not connect");
$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";
}
?>
]]>
</programlisting>
<para>
The above example would produce the following output:
</para>
<screen>
<![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
]]>
</screen>
</example>
</para>
<note>
<para>
This function used to be called <literal>pg_fieldname()</literal>.
</para>
</note>
<para>
See also <function>pg_field_num</function>.
</para>
</refsect1>
</refentry>
<!-- 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
sgml-default-dtd-file:"../../../../manual.ced"
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
-->