<?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.7 $ --> <!-- splitted from ./en/functions/pgsql.xml, last change in rev 1.2 --> <refentry id="function.pg-field-num"> <refnamediv> <refname>pg_field_num</refname> <refpurpose>Returns the field number of the named field</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>int</type><methodname>pg_field_num</methodname> <methodparam><type>resource</type><parameter>result</parameter></methodparam> <methodparam><type>string</type><parameter>field_name</parameter></methodparam> </methodsynopsis> <para> <function>pg_field_num</function> will return the number of the field number that corresponds to the <parameter>field_name</parameter> in the given PostgreSQL <parameter>result</parameter> resource. </para> <note> <para> This function used to be called <function>pg_fieldnum</function>. </para> </note> </refsect1> <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_name</parameter></term> <listitem> <para> The name of the field. </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> The field number (numbered from 0), or -1 on error. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>Getting information about fields</title> <programlisting role="php"> <![CDATA[ <?php $dbconn = pg_connect("dbname=publisher") or die("Could not connect"); $res = pg_query($dbconn, "select author, year, title from authors where author = 'Orwell'"); echo "Column 'title' is field number: ", pg_field_num($res, 'title'); ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ Column 'title' is field number: 2 ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>pg_field_name</function></member> </simplelist> </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 -->