mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-27 14:28:56 +00:00

for file in `ack -i '\bA\s+SQL' -l`; do perl -i -pe 's/\b(a)(\s+SQL)/\1n\2/gi' $file; done git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@300101 c90b9560-bf6c-de11-be94-00142212c4b1
132 lines
4.5 KiB
XML
132 lines
4.5 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
|
|
<refentry xml:id="ref.pdo-4d.sql4d" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
<refnamediv>
|
|
<refname>SQL acceptable by 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>Characteristics</entry>
|
|
<entry>Alternative</entry>
|
|
<entry>Note</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>INTEGER</entry>
|
|
<entry>Modify the SQL to use INT.</entry>
|
|
<entry>INT is the supported integer type in 4Dv12.0.</entry>
|
|
</row>
|
|
<row>
|
|
<entry>CHAR</entry>
|
|
<entry>Use VARCHAR instead.</entry>
|
|
<entry>Unsupported in 4Dv12.0</entry>
|
|
</row>
|
|
<row>
|
|
<entry>UNION</entry>
|
|
<entry>Unsupported. Make separate queries.</entry>
|
|
<entry>Unsupported in 4Dv12.0</entry>
|
|
</row>
|
|
<row>
|
|
<entry>SELECT 1 + 1;</entry>
|
|
<entry>SELECT 1 + 1 FROM _USER_SCHEMAS;</entry>
|
|
<entry>FROM is required</entry>
|
|
</row>
|
|
<row>
|
|
<entry>FLOAT</entry>
|
|
<entry>Cast the FLOAT value into a FLOAT or STRING, with an SQL 4D function (CAST, ROUND, TRUNC or TRUNCATE)</entry>
|
|
<entry>Unsupported in current versions of the PDO_4D driver</entry>
|
|
</row>
|
|
<row>
|
|
<entry>Strong typing</entry>
|
|
<entry>Take care your SQL query, or your PHP code provides data with the expected type</entry>
|
|
<entry>
|
|
One must provide the right type that 4D expect. One can't insert '1' (as a string) in an INTEGER column.
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry><function>PDO::execute($row)</function> : only works if all the table's column are of type TEXT or VARCHAR</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>
|
|
<row>
|
|
<entry>SELECT NULL FROM TABLE</entry>
|
|
<entry>Do not use NULL constants. Extract them from the table</entry>
|
|
<entry>It is not allowed to use the NULL constant in the select list</entry>
|
|
</row>
|
|
<row>
|
|
<entry>SELECT * FROM TABLE WHERE 1</entry>
|
|
<entry>Use WHERE 1 = 1</entry>
|
|
<entry>A constant can't be used in a WHERE clause</entry>
|
|
</row>
|
|
<row>
|
|
<entry>SHOW TABLES</entry>
|
|
<entry>Use system tables</entry>
|
|
<entry>
|
|
The list of tables, schemas, index, etc. are in these system tables :
|
|
<literal>_USER_TABLES</literal>, <literal>_USER_COLUMNS</literal>,
|
|
<literal>_USER_INDEXES</literal>, <literal>_USER_CONSTRAINTS</literal>,
|
|
<literal>_USER_IND_COLUMNS</literal>, <literal>_USER_CONS_COLUMNS</literal>,
|
|
and <literal>_USER_SCHEMAS</literal>.
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>SQL structure delimiter</entry>
|
|
<entry>
|
|
Use the following function to protect SQL elements:
|
|
function sqlEscapeElement(elem) {
|
|
return '[' . str_replace(']',']]', $elem) . ']';
|
|
}
|
|
</entry>
|
|
<entry>
|
|
To escape SQL elements names (tables, fields, users,
|
|
groups, schema, primary key, etc.), the whole identifier
|
|
must be between square brackets, and the closing
|
|
brackets ']' must be doubled.
|
|
</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:"~/.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
|
|
-->
|
|
|