cvs: peardoc /en/package/database/mdb2 intro-function-module.xml intro-module.xml
| From: | Lorenzo Alberton | Date: | Sun, 16 Nov 2008 22:16:32 +0000 |
| Subject: | cvs: peardoc /en/package/database/mdb2 intro-function-module.xml intro-module.xml | ||
| Groups: | php.pear.doc | ||
| Request: | Send a blank email to pear-doc+get-11273@lists.php.net to get a copy of this message | ||
quipo Sun Nov 16 22:16:32 2008 UTC
Added files:
/peardoc/en/package/database/mdb2 intro-function-module.xml
Modified files:
/peardoc/en/package/database/mdb2 intro-module.xml
Log:
initial docs for the Function module
http://cvs.php.net/viewvc.cgi/peardoc/en/package/database/mdb2/intro-module.xml?r1=1.18&r2=1.19&diff_format=u
Index: peardoc/en/package/database/mdb2/intro-module.xml
diff -u peardoc/en/package/database/mdb2/intro-module.xml:1.18
peardoc/en/package/database/mdb2/intro-module.xml:1.19
--- peardoc/en/package/database/mdb2/intro-module.xml:1.18 Thu Oct 9 15:16:24 2008
+++ peardoc/en/package/database/mdb2/intro-module.xml Sun Nov 16 22:16:32 2008
@@ -29,7 +29,8 @@
</listitem>
<listitem>
<simpara>
- Function module (<link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://pear.php.net/package/MDB2/docs/latest/MDB2/MDB2_Driver_Function_Common.html">API</link>)
+ <link linkend="package.database.mdb2.intro-function-module">Function
module</link>
+ (<link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://pear.php.net/package/MDB2/docs/latest/MDB2/MDB2_Driver_Function_Common.html">API</link>)
- handles SQL function abstraction via the
<classname>MDB2_Function_Common</classname>
class
</simpara>
http://cvs.php.net/viewvc.cgi/peardoc/en/package/database/mdb2/intro-function-module.xml?view=markup&rev=1.1
Index: peardoc/en/package/database/mdb2/intro-function-module.xml
+++ peardoc/en/package/database/mdb2/intro-function-module.xml
<?xml version="1.0" encoding="utf-8"?>
<refentry xmlns="http://docbook.org/ns/docbook"
version="lillet" xml:id="package.database.mdb2.intro-function-module">
<refnamediv>
<refname>Function Module</refname>
<refpurpose>Module to handle SQL function abstraction</refpurpose>
</refnamediv>
<refsection xml:id="package.database.mdb2.intro-function-module.desc">
&title.desc;
<para>
The Function module provides methods for executing non-standard SQL database functions in a
consistent way.
The following document lists the available methods, providing examples of their use.
To include the Function module functionality, you need to load it first.
<example><info><title>Loading the Function module</title></info>
<programlisting role="php">
<![CDATA[
<?php
require_once 'MDB2.php';
$dsn = 'pgsql://someuser:apasswd@somehost';
$mdb2 =& MDB2::factory($dsn);
if (PEAR::isError($mdb2)) {
die($mdb2->getMessage());
}
// loading the Function module
$mdb2->loadModule('Function');
?>
]]>
</programlisting>
</example>
After including the module, you can access its methods like this:
<example><info><title>Get the length of a string
expression</title></info>
<programlisting role="php">
<![CDATA[
<?php
// PHP5
$mdb2->length('expression');
// PHP4 and PHP5
$mdb2->function->length('expression');
?>
]]>
</programlisting>
</example>
Further in the document the PHP5-compatible way will be used.
</para>
</refsection>
<refsection
xml:id="package.database.mdb2.intro-function-module.concat"><info><title>Concatenate
strings</title></info>
<para>
<programlisting role="php">
<![CDATA[
<?php
$mdb2->concat('string1', 'string2');
?>
]]>
</programlisting>
</para>
<refsection
xml:id="package.database.mdb2.intro-function-module.create-elements.executeStoredProc"><info><title>Execute
a Stored Procedure</title></info>
<para>
Supposing we have the following Stored Procedure (MySQL syntax):
<programlisting role="sql">
<![CDATA[
DELIMITER //
CREATE PROCEDURE procedure1 (IN parameter1 INTEGER)
BEGIN
DECLARE variable1 CHAR(10);
IF parameter1 = 17 THEN
SET variable1 = 'birds';
ELSE
SET variable1 = 'beasts';
END IF;
INSERT INTO table1 VALUES (variable1);
END
//
DELIMITER ;
]]>
</programlisting>
we can call it this way:
<example><info><title>Execute a Stored Procedure</title></info>
<programlisting role="php">
<![CDATA[
<?php
$params = array(17);
$mdb2->executeStoredProc('procedure1', $params);
?>
]]>
</programlisting>
</example>
</para>
</refsection>
</refentry>