Each database management system (DBMS) has it's own behaviors. For example, some databases capitalize field names in their output, some lowercase them, while others leave them alone. These quirks make it difficult to port your scripts over to another server type. PEAR MDB2 strives to overcome these differences so your program can switch between DBMS's without any changes.
You control which portability modes are enabled by using the portability configuration option. Configuration options are set via factory() and setOption().
The portability modes are bitwised, so they can be combined using | and removed using ^. See the examples section below on how to do this.
MDB2_PORTABILITY_ALL (default)
turn on all portability features. this is the default setting.
MDB2_PORTABILITY_DELETE_COUNT
Force reporting the number of rows deleted. Some DBMS's don't count the number of rows deleted when performing simple DELETE FROM tablename queries. This mode tricks such DBMS's into telling the count by adding WHERE 1=1 to the end of DELETE queries.
MDB2_PORTABILITY_EMPTY_TO_NULL
Convert empty strings values to null in data in and output. Needed because Oracle considers empty strings to be null, while most other DBMS's know the difference between empty and null.
MDB2_PORTABILITY_ERRORS
Makes certain error messages in certain drivers compatible with those from other DBMS's
Таблица 34-1. Error Code Re-mappings
Driver | Description | Old Constant | New Constant |
---|---|---|---|
mysql, mysqli | unique and primary key constraints | MDB2_ERROR_ALREADY_EXISTS | MDB2_ERROR_CONSTRAINT |
mysql, mysqli | not-null constraints | MDB2_ERROR_CONSTRAINT | MDB2_ERROR_CONSTRAINT_NOT_NULL |
Пример 34-1. Disabling all portability options while connecting
|
Пример 34-2. Using setOption() to enable portability for lowercasing and trimming
|
Пример 34-3. Using setOption() to enable all portability options except trimming
|
Пред. | Начало | След. |
autoPrepare & autoExecute | Уровень выше | Sequences |
HIVE: All information for read only. Please respect copyright! |