Files
php-doc-ru/reference/pgsql/examples.xml
Alexey Pyltsyn 77ba7fb0ef pgsql: review
git-svn-id: https://svn.php.net/repository/phpdoc/ru/trunk@345589 c90b9560-bf6c-de11-be94-00142212c4b1
2018-09-03 14:20:18 +00:00

70 lines
2.1 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"?>
<!-- EN-Revision: 79dcbe011fb254dcd92c597064571fe313362a09 Maintainer: aur Status: ready -->
<!-- Reviewed: yes -->
<!-- $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">
<title>Базовое использование</title>
<para>
Этот простой пример показывает как выполнить соединение с БД,
отправить запрос, вывести его результат и закрыть соединение с PostgreSQL.
<example>
<title>Пример работы с расширением PostgreSQL</title>
<programlisting role="php">
<![CDATA[
<?php
// Соединение, выбор базы данных
$dbconn = pg_connect("host=localhost dbname=publishing user=www password=foo")
or die('Не удалось соединиться: ' . pg_last_error());
// Выполнение SQL-запроса
$query = 'SELECT * FROM authors';
$result = pg_query($query) or die('Ошибка запроса: ' . 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:"~/.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
-->