Files
php-doc-ru/reference/pgsql/examples.xml
Nilgün Belma Bugüner 2db753bdad changed EN-Revision tag as cvs2svn;
fixed svn properties

git-svn-id: https://svn.php.net/repository/phpdoc/ru/trunk@283930 c90b9560-bf6c-de11-be94-00142212c4b1
2009-07-12 06:01:07 +00:00

68 lines
1.8 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<chapter xml:id="pgsql.examples" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
&reftitle.examples;
<section xml:id="pgsql.examples-basic">
<para>
Это простой пример соединения, выполнения запроса, вывода результата
и закрытия соединения с базой данной PostgreSQL.
<example>
<title>Общий пример работы с расширением PostgreSQL</title>
<programlisting role="php">
<![CDATA[
<?php
// Соединение, выбор базы данных
$dbconn = pg_connect("host=localhost dbname=publishing user=www password=foo")
or die('Could not connect: ' . pg_last_error());
// Выполнение SQL запроса
$query = 'SELECT * FROM authors';
$result = pg_query($query) or die('Query failed: ' . pg_last_error());
// Вывод результатов в HTML
echo "<table>\n";
while ($line = pg_fetch_array($result, null, PGSQL_ASSOC)) {
echo "\t<tr>\n";
foreach ($line as $col_value) {
echo "\t\t<td>$col_value</td>\n";
}
echo "\t</tr>\n";
}
echo "</table>\n";
// Очистка результата
pg_free_result($result);
// Закрытие соединения
pg_close($dbconn);
?>
]]>
</programlisting>
</example>
</para>
</section>
</chapter>
<!-- 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
-->