(No version information available, might only be in CVS)
SQL acceptable by 4D — PDO and SQL 4D
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 : » http://www.4d.fr/support/docs.html. Below is a list of 4D SQL characteristics: it is not exhaustive, but may serve as an introduction.
Ch aracteristics | Alternative | Note |
---|---|---|
INTEGER | INT is the supported integer type. Modify the SQL to use INT. | |
UNION | Unsupported. Make separate queries. | |
LEFT JOIN | Use the SQL 89 notation (see example #3 PDO_4D) | |
SELECT 1 + 1; | SELECT 1 + 1 FROM _USER_SCHEMAS; | |
FLOAT | Cast the FLOAT value with a SQL 4D function (ROUND, TRUNC or TRUNCATE) | Unsupported in the driver PDO_4D v1.0 |
Strong typing : one must provide the right type that 4D expect. One can't insert '1' (as a string) in an INTEGER column. | Modify your SQL query, or your PHP to adapt the type | Unsupported |
PDO::execute($row)() only works if all the table's column are of type TEXT | Use the prepared statements, and use the right types. | The PDO extension cast all values through execute() as string, and expect the SQL database to parse the values. |
SELECT NULL FROM TABLE | It is not allowed to use the NULL constante in the select list | Do not use NULL constants. Extract them from the table |
SELECT * FROM TABLE WHERE 1 | A constant can't be used in a WHERE clause. | Use 1 = 1 |
SHOW TABLES | The list of tables, schemas, index, etc. are in 7 4D tables | Use _USER_TABLES, _USER_COLUMNS, _USER_INDEXES, _USER_CONSTRAINTS, _USER_IND_COLUMNS, _USER_CONS_COLUMNS, and _USER_SCHEMAS. |
SQL structure delimiter | To escape SQL elements (tables, fields, users, groups, schema, primary key, etc.), closing brackets must be doubled, and the whole identifier must be between square brackets. | Use the following function to protect SQL objects, and then, put it between square brackets : str_replace(']',']]', $table). |
Note: In version 11.3 and below, it wasn't possible to use the SQL syntax id INT PRIMARY KEY 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.