php-doc-en/reference/ingres-ii/examples.xml

75 lines
1.8 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<chapter xml:id="ingres.examples" xmlns="http://docbook.org/ns/docbook">
&reftitle.examples;
<section xml:id="ingres.examples-basic">
<title>Basic usage</title>
<para>
The following simple example shows how to connect to an Ingres database,
execute a query, print
resulting rows and disconnect from the database.
<example>
<title>Simple Ingres Example</title>
<programlisting role="php">
<![CDATA[
<?php
// Connecting, selecting database
$link = ingres_connect("database", "user", "password")
or die("Could not connect: " . ingres_error($link));
echo "Connected successfully";
// Select from a table that exists in all Ingres databases
$query = "SELECT * FROM iitables";
$result = ingres_query($link,$query) or die("Query failed: " .
ingres_error($link));
// Print results in HTML
// relid - table name
// relowner - table owner
echo "<table>\n";
while ($iitables = ingres_fetch_object($result)) {
echo "\t<tr>\n";
echo "\t\t<td>" . $iitables->relid . "</td>\n";
echo "\t\t<td>" . $iitables->relowner . "</td>\n";
echo "\t</tr>\n";
}
echo "</table>\n";
// Free results
ingres_free_result($result);
// Commit transaction
ingres_commit($link);
// Closing connection
ingres_close($link);
?>
]]>
</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
-->