dbx_query() returns an object or
1 on success, and 0 on failure. The result object is returned
only if the query given in
sql_statement produces a result set.
The flags parameter is
used to control the amount of information that is returned.
It may be any combination of the following constants with the
bitwise OR operator (|). The DBX_COLNAMES_* flags override
the dbx.colnames_case setting from
php.ini.
It is
always set, that is, the returned object has
a data property which is
a 2 dimensional array indexed numerically. For example,
in the expression data[2][3]
2 stands for the row (or
record) number and 3 stands
for the column (or field) number. The first row and
column are indexed at 0.
If
DBX_RESULT_ASSOC is also specified, the
returning object contains the information related to
DBX_RESULT_INFO too,
even if it was not specified.
It provides info about columns, such as field
names and field types.
It effects that the field values can be accessed
with the respective column names used as keys to the
returned object's data
property.
Associated results are actually references to the
numerically indexed data, so modifying data[0][0] causes that data[0]['field_name_for_first_column']
is modified as well.
The case of the returned column names will not be
changed.
The case of the returned column names will be
changed to uppercase.
The case of the returned column names will be
changed to lowercase.
DBX_RESULT_INDEX |
DBX_RESULT_INFO | DBX_RESULT_ASSOC - this is
the default, if flags
is not specified.
The returing object has four or
five properties depending on
flags:
It is a valid handle for the connected database,
and as such it can be used in module specific functions
(if required).
These contain the number of columns (or fields)
and rows (or records) respectively.
$result = dbx_query ($link, 'SELECT id FROM table'); echo $result- rows; // number of records echo $result- cols; // number of fields |
It is returned only if either DBX_RESULT_INFO or DBX_RESULT_ASSOC is specified in
the flags parameter.
It is a 2 dimensional array, that has two named rows
(name and
type) to retrieve column information.
This property contains the actual resulting data,
possibly associated with column names as well depending
on flags. If DBX_RESULT_ASSOC is set,
it is possible to use
$result- data[2]["field_name"].
注: Always refer to the module-specific documentation as well.
Column names for queries on an Oracle database are returned in lowercase.
See also: dbx_escape_string() and
dbx_connect().