mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-15 16:38:54 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@329325 c90b9560-bf6c-de11-be94-00142212c4b1
143 lines
3.9 KiB
XML
143 lines
3.9 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- splitted from ./en/functions/pgsql.xml, last change in rev 1.16 -->
|
|
<refentry xml:id="function.pg-set-client-encoding" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>pg_set_client_encoding</refname>
|
|
<refpurpose>
|
|
Set the client encoding
|
|
</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>int</type><methodname>pg_set_client_encoding</methodname>
|
|
<methodparam choice="opt"><type>resource</type><parameter>connection</parameter></methodparam>
|
|
<methodparam><type>string</type><parameter>encoding</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>pg_set_client_encoding</function> sets the client
|
|
encoding and returns 0 if success or -1 if error.
|
|
</para>
|
|
<para>
|
|
PostgreSQL will automatically convert data in the backend database
|
|
encoding into the frontend encoding.
|
|
</para>
|
|
<note>
|
|
<para>
|
|
The function used to be called
|
|
<function>pg_setclientencoding</function>.
|
|
</para>
|
|
</note>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>connection</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
PostgreSQL database connection resource. When
|
|
<parameter>connection</parameter> is not present, the default connection
|
|
is used. The default connection is the last connection made by
|
|
<function>pg_connect</function> or <function>pg_pconnect</function>.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>encoding</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
The required client encoding. One of <literal>SQL_ASCII</literal>, <literal>EUC_JP</literal>,
|
|
<literal>EUC_CN</literal>, <literal>EUC_KR</literal>, <literal>EUC_TW</literal>,
|
|
<literal>UNICODE</literal>, <literal>MULE_INTERNAL</literal>, <literal>LATINX</literal> (X=1...9),
|
|
<literal>KOI8</literal>, <literal>WIN</literal>, <literal>ALT</literal>, <literal>SJIS</literal>,
|
|
<literal>BIG5</literal> or <literal>WIN1250</literal>.
|
|
</para>
|
|
<para>
|
|
The exact list of available encodings depends on your PostgreSQL version, so check your
|
|
PostgreSQL manual for a more specific list.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Returns 0 on success or -1 on error.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title><function>pg_set_client_encoding</function> example</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
|
|
$conn = pg_pconnect("dbname=publisher");
|
|
if (!$conn) {
|
|
echo "An error occurred.\n";
|
|
exit;
|
|
}
|
|
|
|
// Set the client encoding to UNICODE. Data will be automatically
|
|
// converted from the backend encoding to the frontend.
|
|
pg_set_client_encoding($conn, "UNICODE");
|
|
|
|
$result = pg_query($conn, "SELECT author, email FROM authors");
|
|
if (!$result) {
|
|
echo "An error occurred.\n";
|
|
exit;
|
|
}
|
|
|
|
// Write out UTF-8 data
|
|
while ($row = pg_fetch_row($result)) {
|
|
echo "Author: $row[0] E-mail: $row[1]";
|
|
echo "<br />\n";
|
|
}
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>pg_client_encoding</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
|
|
-->
|