PEAR DB is written to support many database
types. Not all things work quite the same way in all of them. Oracle
is no exception, and if all features are to work as expected,
portability options will need set. This is done either as an
argument to the connect function or by the setOption() method
in the DB connection class. The setOption() function has a
very simple syntax:
$db->setOption(option,value);
The available options from the online manual are
listed in the table below, together with the values for the
“portability” option.
OPTION |
DATA TYPE |
DEFAULT
VALUE |
DESCRIPTION |
Autofree
|
boolean
|
false
|
Should
results be freed automatically when there are no more rows?
|
debug
|
Integer
|
0
|
Debug level
|
persistent
|
boolean
|
false
|
Should the
connection be persistent? |
portability
|
Integer
|
db_portability_none
|
Portability
mode constant. These constants are bit wised, so they can be
combined using
|
and removed using
^.
See the examples below and the "Intro - Portability" for more
information. |
Seqname_format |
string
|
%s_seq
|
the sprintf()
format string used on sequence names. This format is applied to
sequence names passed to createSequence(), nextID() and
dropSequence(). |
ssl
|
boolean
|
false
|
Use ssl to
connect? |
The available values for the ‘portability’ option
are as follows:
·
DB_PORTABILITY_LOWERCASE - This option converts
the names of tables and fields to lower case when using the get*(),
fetch*() and tableInfo() function.
·
DB_PORTABILITY_NONE (default) - This option turns
off all portability features.
·
DB_PORTABILITY_NULL_TO_EMPTY - This
option converts NULL values to empty strings in the data output by the
get*() and fetch*() function. This is required because
Oracle considers empty strings to be NULL, while most other DBMSs know
the difference between empty and NULL.
·
DB_PORTABILITY_NUMROWS - This option enables a
hack allowing the numRows() function to work in Oracle.
·
DB_PORTABILITY_RTRIM - This option right trims the data output by the get*()
and fetch*() function.
More than one option can be specified at a time by
using the bitwise or the operator “|”, as shown below:
$db->setOption('portability',
DB_PORTABILITY_NUMROWS |
DB_PORTABILITY_NULL
If
the DB_PORTABILITY_NUMROWS bit is not set, the numRows()
method of the result set does not work and the rows cannot be counted
except by using the count() SQL function.