cvs: phpdoc /en/reference/pdo_4d examples.xml
| From: | Damien Seguy | Date: | Fri, 22 May 2009 10:24:08 +0000 |
| Subject: | cvs: phpdoc /en/reference/pdo_4d examples.xml | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-4055@lists.php.net to get a copy of this message | ||
dams Fri May 22 10:24:08 2009 UTC
Modified files:
/phpdoc/en/reference/pdo_4d examples.xml
Log:
adding escaping example
http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/pdo_4d/examples.xml?r1=1.1&r2=1.2&diff_format=u
Index: phpdoc/en/reference/pdo_4d/examples.xml
diff -u phpdoc/en/reference/pdo_4d/examples.xml:1.1 phpdoc/en/reference/pdo_4d/examples.xml:1.2
--- phpdoc/en/reference/pdo_4d/examples.xml:1.1 Wed Apr 22 13:52:44 2009
+++ phpdoc/en/reference/pdo_4d/examples.xml Fri May 22 10:24:08 2009
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<!-- $Revision: 1.1 $ -->
+<!-- $Revision: 1.2 $ -->
<refentry xml:id="pdo-4d.examples" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
@@ -194,6 +194,64 @@
</example>
</para>
</refsect1>
+
+ <refsect1 role="description">
+ <para>
+ <example>
+ <title>Escaping 4D table names</title>
+ <para>
+ This examples illustrates how to escape characters in a
+ 4D SQL query.
+ </para>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$dsn = '4D:host=localhost;charset=UTF-8';
+$user = 'test';
+$pass = 'test';
+Â
+// Connection to 4D server 4D
+$db = new PDO_4D($dsn, $user, $pass);
+
+$objects =
array('[',']','[]','][','[[',']]','[[[',']]]','TBL
]]32[23');
+
+foreach($objects as $id => $object) {
+ $object = str_replace(']',']]', $object);
+ print "$object\n";
+
+ $db->exec('CREATE TABLE IF NOT EXISTS ['.$object.'](['.$object.']
FLOAT)');
+
+ $req = "INSERT INTO [$object] ([$object]) VALUES ($id);";
+ $db->query($req);
+
+ $q = $db->prepare("SELECT [$object] FROM [$object]");
+ $q->execute();
+ $x[] = $q->fetch(PDO::FETCH_NUM);
+
+ $db->exec('DROP TABLE ['.$object.'];');
+}
+
+?>
+]]>
+ </programlisting>
+ </example>
+ &example.outputs;
+ <screen>
+<![CDATA[
+[
+]]
+[]]
+]][
+[[
+]]]]
+[[[
+]]]]]]
+TBL ]]]]32[23
+]]>
+ </screen>
+ </para>
+ </refsect1>
+
</refentry>
<!-- Keep this comment at the end of the file