initial documentation

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@279153 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Damien Seguy 2009-04-22 13:52:44 +00:00
parent d00ef41bf3
commit f21aba621a
7 changed files with 913 additions and 0 deletions

View file

@ -0,0 +1,61 @@
<?xml version='1.0' encoding='utf-8'?>
<!-- $Revision: 1.1 $ -->
<refentry xml:id="pdo-4d.constants">
<refnamediv>
<refname>Constants for PDO_4D</refname>
<refpurpose>Constants for PDO_4D</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.constants;
&pdo.driver-constants;
<variablelist>
<varlistentry>
<term>
<constant>PDO::FOURD_ATTR_CHARSET</constant>
(<type>integer</type>)
</term>
<listitem>
<para>
Change the charset in which 4D returns data.
(Default is UTF-8).
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<constant>PDO::FOURD_ATTR_PREFERRED_IMAGE_TYPES</constant>
(<type>integer</type>)
</term>
<listitem>
<para>
The requested format of the image, when selecting a row
with a column type PICTURE. It may be any type that 4D supports.
</para>
</listitem>
</varlistentry>
</variablelist>
</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:"../../../../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
-->

104
reference/pdo_4d/dsn.xml Normal file
View file

@ -0,0 +1,104 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 1.1 $ -->
<refentry xml:id="ref.pdo-4d.connection">
<refnamediv>
<refname>PDO_4D DSN</refname>
<refpurpose>Connecting to 4D SQL server</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<para>
The PDO_4D DSN consists of:
<variablelist>
<varlistentry>
<term>DSN prefix</term>
<listitem>
<para>
The DSN prefix is <userinput>4D:</userinput>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><constant>host</constant></term>
<listitem>
<para>
The host on which the 4D SQL server is.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><constant>port</constant></term>
<listitem>
<para>
The port number for the server. This is optional.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><constant>dbname</constant></term>
<listitem>
<para>
The name of the database. This parameter is optional,
and it is not used.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><constant>chars_set</constant></term>
<listitem>
<para>
The 4D character set.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>DSN examples for PDO_4D</title>
<para>
The following examples has two DSN for PDO_4D,
that connects to a 4D database :
<programlisting>
<![CDATA[
4D:host=localhost;charset=UTF-8
]]>
</programlisting>
Other possible values :
<programlisting>
<![CDATA[
4D:host=localhost
]]>
</programlisting>
</para>
</example>
</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:"../../../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
-->

View file

@ -0,0 +1,219 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 1.1 $ -->
<refentry xml:id="pdo-4d.examples" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>Examples with PDO_4D</refname>
<refpurpose>Examples PDO_4D</refpurpose>
</refnamediv>
<refsect1 role="description">
<para>
This basic example show how to connect, execute a query,
read data and disconnect from a 4D SQL server.
<example>
<title>Basic example with PDO_4D</title>
<programlisting role="php">
<![CDATA[
<?php
$dsn = '4D:host=localhost;charset=UTF-8';
$user = 'test';
$pass = 'test';
// Connection to the 4D SQL server
$db = new PDO_4D($dsn, $user, $pass);
try {
$db->exec('CREATE TABLE test(id varCHAR(1) NOT NULL, val VARCHAR(10))');
} catch (PDOException $e) {
die("Erreur 4D : " . $e->getMessage());
}
$db->exec("INSERT INTO test VALUES('A', 'A')");
$db->exec("INSERT INTO test VALUES('B', 'A')");
$db->exec("INSERT INTO test VALUES('C', 'C')");
$stmt = $db->prepare('SELECT id, val from test');
$stmt->execute();
print_r($stmt->fetchAll());
unset($stmt);
unset($db);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Array
(
[0] => Array
(
[ID] => A
[0] => A
[VAL] => B
[1] => B
)
[1] => Array
(
[ID] => C
[0] => C
[VAL] => D
[1] => D
)
[2] => Array
(
[ID] => E
[0] => E
[VAL] => F
[1] => F
)
)
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="description">
<para>
This example shows how to execute a query in 4D language,
and how to read the result through PDO_4D.
<example>
<title>Accessing 4D language from pdo_4d</title>
<para>
Set up a 4D method, called <literal>method</literal>. Make sure
in the method properties that the option
<literal>Available via SQL</literal> is checked. The 4D code
is the following.
</para>
<programlisting role="4d">
<![CDATA[
C_TEXTE($0)
$0:=Version application(*);
]]>
</programlisting>
<para>
The PHP code to use the above 4D method is :
</para>
<programlisting role="php">
<![CDATA[
<?php
$dsn = '4D:host=localhost;charset=UTF-8';
$user = 'test';
$pass = 'test';
// Connection to the 4D server
$db = new pdo($dsn, $user, $pass);
$stmt = $db->prepare('SELECT {FN method() AS VARCHAR } FROM _USER_SCHEMAS LIMIT 1');
$stmt->execute();
print_r($stmt->fetchAll()) ;
unset($stmt);
unset($db);
?>]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
(
[0] => Array
(
[<expression>] => F0011140
[0] => F0011140
)
)
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="description">
<para>
<example>
<title>Executing a LEFT JOIN in 4D</title>
<para>
This example shows how to execute a LEFT JOIN SQL query, with 4D.
</para>
<programlisting role="php">
<![CDATA[
<?php
$dsn = '4D:host=localhost;charset=UTF-8';
$user = 'test';
$pass = 'test';
 
// Connection to the 4D SQL server
$db = new PDO_4D($dsn, $user, $pass);
 
/* The SQL query is the equivalent of the following LEFT JOIN
SELECT
  classtypes.name,
  test.id AS id,
  test.val AS val
FROM
  test
LEFT JOIN
  classtypes
ON
  test.classtype=classtypes.id
*/
 
// Using SQL-89 Notation
$query = <<<SQL
SELECT
  classtypes.name,
  test.id AS id,
  test.val AS val
FROM
  test,
  classtypes
WHERE
  test.classtype=classtypes.id
  OR test.classtype IS NULL
SQL;
 
$stmt = $db->prepare($query);
$stmt->execute();
       
print_r($stmt->fetchAll());
 
$stmt = null;
$db = null;
?>
]]>
</programlisting>
</example>
</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:"../../../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
-->

180
reference/pdo_4d/ini.xml Normal file
View file

@ -0,0 +1,180 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 1.1 $ -->
<section xml:id="pdo-4d.configuration" xmlns="http://docbook.org/ns/docbook">
&reftitle.runtime;
&extension.runtime;
<para>
<table>
<title>&ConfigureOptions; PDO_4D</title>
<tgroup cols="4">
<thead>
<row>
<entry>&Name;</entry>
<entry>&Default;</entry>
<entry>&Changeable;</entry>
<entry>&Changelog;</entry>
</row>
</thead>
<tbody>
<row>
<entry><link linkend="ini.pdo-4d.defaut_host">pdo_4d.default_host</link></entry>
<entry>"localhost"</entry>
<entry>PHP_INI_ALL</entry>
<entry></entry>
</row>
<row>
<entry><link linkend="ini.pdo-4d.default_port">pdo_4d.default_port</link></entry>
<entry>19812</entry>
<entry>PHP_INI_ALL</entry>
<entry></entry>
</row>
<row>
<entry><link linkend="ini.pdo-4d.default_user">pdo_4d.default_user</link></entry>
<entry>""</entry>
<entry>PHP_INI_ALL</entry>
<entry></entry>
</row>
<row>
<entry><link linkend="ini.pdo-4d.default_password">pdo_4d.default_password</link></entry>
<entry></entry>
<entry>PHP_INI_ALL</entry>
<entry></entry>
</row>
<row>
<entry><link linkend="ini.pdo-4d.connect_timeout">pdo_4d.connect_timeout</link></entry>
<entry>60</entry>
<entry>PHP_INI_ALL</entry>
<entry></entry>
</row>
<row>
<entry><link linkend="ini.pdo-4d.charset">pdo_4d.charset</link></entry>
<entry>utf-16</entry>
<entry>PHP_INI_ALL</entry>
<entry></entry>
</row>
<row>
<entry><link linkend="ini.pdo-4d.prefered_image_type">pdo_4d.prefered_image_type</link></entry>
<entry>"JPEG"</entry>
<entry>PHP_INI_ALL</entry>
<entry></entry>
</row>
</tbody>
</tgroup>
</table>
&ini.php.constants;
</para>
&ini.descriptions.title;
<para>
<variablelist>
<varlistentry xml:id="ini.pdo-4d.default_host">
<term>
<parameter>pdo_4d.default_host</parameter>
<type>string</type>
</term>
<listitem>
<para>
The default host.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="ini.pdo-4d.default_port">
<term>
<parameter>pdo_4d.default_port</parameter>
<type>string</type>
</term>
<listitem>
<para>
The default port number for the connexion.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="ini.pdo-4d.default_user">
<term>
<parameter>pdo_4d.default_user</parameter>
<type>string</type>
</term>
<listitem>
<para>
The default 4D user.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="ini.pdo-4d.default_password">
<term>
<parameter>pdo_4d.default_password</parameter>
<type>string</type>
</term>
<listitem>
<para>
The default password.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="ini.pdo-4d.connect_timeout">
<term>
<parameter>pdo_4d.connect_timeout</parameter>
<type>string</type>
</term>
<listitem>
<para>
The expiration time for the connexion to the 4D SQL server.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="ini.pdo-4d.charset">
<term>
<parameter>pdo_4d.charset</parameter>
<type>string</type>
</term>
<listitem>
<para>
The data charset.
</para>
</listitem>
</varlistentry>
<varlistentry xml:id="ini.pdo-4d.prefered_image_type">
<term>
<parameter>pdo_4d.prefered_image_type</parameter>
<type>string</type>
</term>
<listitem>
<para>
The default image format that 4D returns. It may be
any format that 4D supports. For example, JPEG or PNG.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</section>
<!-- 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
-->

View file

@ -0,0 +1,86 @@
<?xml version='1.0' encoding='utf-8'?>
<!-- $Revision: 1.1 $ -->
<!-- Purpose: database.vendors -->
<!-- Membership: bundled, external, pecl -->
<reference xml:id="ref.pdo-4d" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Driver 4D for PDO (PDO_4D)</title>
<titleabbrev>Driver 4D for PDO</titleabbrev>
<partintro>
<section xml:id="pdo-4d.intro">
&reftitle.intro;
&warn.experimental;
<para>
PDO_4D is a driver that implements the
<link linkend="intro.pdo">PHP Data Objects (PDO)</link> interface
to enable access from PHP to 4D databases.
</para>
<para>
4D is an integrated platform that speeds and simplifies the development
and deployment of business applications, used in over 70 countries, by
a community of thousands of developers and vertical solution providers,
with millions of end-users worldwide.
</para>
<para>
By offering a suite of integrated tools such as an ANSI SQL relational
and transactional database, a graphical development environment, a
fourth-generation language with over 1000 high-level commands, a
built-in HTTP server, application server, etc., 4D facilitates the
creation and maintenance of applications from one to hundreds of
simultaneous users, whether on Windows, Mac or from any Web client.
</para>
<para>
4D is also an open platform, offering a complete API for plug-in
creation, including various connectors that allow it to act as a
back-end or front-end for many environments (Oracle via OCI, SOAP
client or server, Flex data source, all ODBC databases, XML over
HTTP, etc.)
</para>
<para>
In addition to the ability to interact with 4D applications across
Web Services, 4D databases can now be directly accessed using the
PDO_4D driver.
</para>
<para>
More details about the 4D development environment on www.4D.com
</para>
<para>
PDO_4D has been developed to work on Windows (Vista),
Mac OS X (10.5) and Linux (Debian-tested). It is known to work with
4D versions 11.4 and up, for Mac OS X and Windows. Older
plat-forms may work, but are unsupported.
</para>
</section>
</partintro>
&reference.pdo-4d.dsn;
&reference.pdo-4d.constants;
&reference.pdo-4d.sqltypes;
&reference.pdo-4d.sql4d;
&reference.pdo-4d.examples;
<!--
-->
</reference>
<!-- 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
-->

103
reference/pdo_4d/sql4d.xml Normal file
View file

@ -0,0 +1,103 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 1.1 $ -->
<refentry xml:id="ref.pdo-4d.sql4d" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>Indications sur le SQL supporté par 4D</refname>
<refpurpose>PDO and SQL 4D</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<para>
4D implements strictly the ANSI 89 standard, and have it enforced.
It is highly recommended to read the 4D SQL documentation to learn
about the available commands. The URL of the manual is :
<link xlink:href="&url.4d.doc;">&url.4d.doc;</link>.
Below is a list of 4D SQL characteristics: it is not exhaustive,
but may serve as an introduction.
</para>
<para>
<table>
<title>Characteristics of 4D SQL</title>
<tgroup cols="3">
<thead>
<row>
<entry>Ch
aracteristics</entry>
<entry>Alternative</entry>
<entry>Note</entry>
</row>
</thead>
<tbody>
<row>
<entry>INTEGER</entry>
<entry>INT is the supported integer type. Modify the SQL to use INT.</entry>
<entry></entry>
</row>
<row>
<entry>UNION</entry>
<entry>Unsupported. Make separate queries.</entry>
<entry></entry>
</row>
<row>
<entry>LEFT JOIN</entry>
<entry>Use the SQL 89 notation (see example #3 PDO_4D)</entry>
<entry></entry>
</row>
<row>
<entry>SELECT 1 + 1;</entry>
<entry>SELECT 1 + 1 FROM _USER_SCHEMAS;</entry>
<entry></entry>
</row>
<row>
<entry>FLOAT</entry>
<entry>Cast the FLOAT value with a SQL 4D function (ROUND, TRUNC or TRUNCATE)</entry>
<entry>Unsupported in the driver PDO_4D v1.0</entry>
</row>
<row>
<entry>Strong typing : one must provide the right type that 4D expect. One can't insert '1' (as a string) in an INTEGER column.</entry>
<entry>Modify your SQL query, or your PHP to adapt the type</entry>
<entry>Unsupported</entry>
</row>
<row>
<entry><function>PDO::execute($row)</function> only works if all the table's column are of type <literal>TEXT</literal></entry>
<entry>Use the prepared statements, and use the right types.</entry>
<entry>The PDO extension cast all values through execute() as string, and expect the SQL database to parse the values.</entry>
</row>
</tbody>
</tgroup>
</table>
</para>
<note>
<para>
In version 11.3 and below, it wasn't possible to use the SQL syntax
<literal>id INT PRIMARY KEY</literal> during the creation of a table.
This have been fixed in 4D 11.4 and up. It is recommended to use
at least version 11.4 with PDO_4D.
</para>
</note>
</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:"../../../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
-->

View file

@ -0,0 +1,160 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 1.1 $ -->
<refentry xml:id="pdo-4d.sqltypes">
<refnamediv>
<refname>SQL types with PDO_4D and PHP</refname>
<refpurpose>SQL types with PDO_4D and PHP</refpurpose>
</refnamediv>
<refsect1 role="description">
<para>
<table>
<title>Supported SQL types</title>
<tgroup cols="3">
<thead>
<row>
<entry>Type SQL 4D</entry>
<entry>Equivalent 4D</entry>
<entry>Note</entry>
</row>
</thead>
<tbody>
<row>
<entry>ALPHA_NUMERIC</entry>
<entry>TEXT</entry>
<entry></entry>
</row>
<row>
<entry>VARCHAR</entry>
<entry>TEXT</entry>
<entry></entry>
</row>
<row>
<entry>TEXT</entry>
<entry>TEXT</entry>
<entry></entry>
</row>
<row>
<entry>TIMESTAMP</entry>
<entry>DATE</entry>
<entry></entry>
</row>
<row>
<entry>INTERVAL</entry>
<entry>HOUR</entry>
<entry></entry>
</row>
<row>
<entry>DURATION</entry>
<entry>HOUR</entry>
<entry></entry>
</row>
<row>
<entry>BOOLEAN</entry>
<entry>BOOLEAN</entry>
<entry></entry>
</row>
<row>
<entry>BIT</entry>
<entry>BOOLEAN</entry>
<entry></entry>
</row>
<row>
<entry>BYTE</entry>
<entry>INT32</entry>
<entry></entry>
</row>
<row>
<entry>INT16</entry>
<entry>SMALLINT</entry>
<entry></entry>
</row>
<row>
<entry>SMALLINT</entry>
<entry>SMALLINT</entry>
<entry></entry>
</row>
<row>
<entry>INT32</entry>
<entry>INT32</entry>
<entry></entry>
</row>
<row>
<entry>INT</entry>
<entry>INT32</entry>
<entry></entry>
</row>
<row>
<entry>INT64</entry>
<entry>INT64</entry>
<entry></entry>
</row>
<row>
<entry>NUMERIC</entry>
<entry>INT64</entry>
<entry></entry>
</row>
<row>
<entry>REAL</entry>
<entry>REAL</entry>
<entry></entry>
</row>
<row>
<entry>FLOAT</entry>
<entry>FLOAT</entry>
<entry>Unsupported</entry>
</row>
<row>
<entry>DOUBLE PRECISION</entry>
<entry>FLOAT</entry>
<entry></entry>
</row>
<row>
<entry>BLOB</entry>
<entry>BLOB</entry>
<entry>Must use a prepared statement, and <constant>PDO::PARAM_LOB</constant></entry>
</row>
<row>
<entry>BIT VARYING</entry>
<entry>BLOB</entry>
<entry>Must use a prepared statement, and <constant>PDO::PARAM_LOB</constant></entry>
</row>
<row>
<entry>CLOB</entry>
<entry>TEXT</entry>
<entry></entry>
</row>
<row>
<entry>PICTURE</entry>
<entry>PICTURE</entry>
<entry>Must use a prepared statement, and <constant>PDO::PARAM_LOB</constant></entry>
</row>
</tbody>
</tgroup>
</table>
</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:"../../../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
-->