mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-20 19:08:54 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@314774 c90b9560-bf6c-de11-be94-00142212c4b1
157 lines
4.3 KiB
XML
157 lines
4.3 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- splitted from ./en/functions/pgsql.xml, last change in rev 1.2 -->
|
|
<refentry xml:id="function.pg-field-prtlen" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>pg_field_prtlen</refname>
|
|
<refpurpose>Returns the printed length</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>int</type><methodname>pg_field_prtlen</methodname>
|
|
<methodparam><type>resource</type><parameter>result</parameter></methodparam>
|
|
<methodparam><type>int</type><parameter>row_number</parameter></methodparam>
|
|
<methodparam><type>mixed</type><parameter>field_name_or_number</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<methodsynopsis>
|
|
<type>int</type><methodname>pg_field_prtlen</methodname>
|
|
<methodparam><type>resource</type><parameter>result</parameter></methodparam>
|
|
<methodparam><type>mixed</type><parameter>field_name_or_number</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>pg_field_prtlen</function> returns the actual printed
|
|
length (number of characters) of a specific value in a PostgreSQL
|
|
<parameter>result</parameter>. Row numbering starts at 0. This
|
|
function will return &false; on an error.
|
|
</para>
|
|
<para>
|
|
<parameter>field_name_or_number</parameter> can be passed either as an
|
|
<type>integer</type> or as a <type>string</type>. If it is passed as an
|
|
<type>integer</type>, PHP recognises it as the field number, otherwise as
|
|
field name.
|
|
</para>
|
|
<para>
|
|
See the example given at the <function>pg_field_name</function> page.
|
|
</para>
|
|
<note>
|
|
<para>
|
|
This function used to be called <function>pg_fieldprtlen</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>row</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Row number in result. Rows are numbered from 0 upwards. If omitted,
|
|
current row is fetched.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
The field printed length, or &false; 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 * 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>
|
|
&example.outputs;
|
|
<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>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>pg_field_size</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:"~/.phpdoc/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
|
|
-->
|