Home > PHP > Function > > dbx_query()

dbx_query()

dbx_query - Send a query and fetch all results (if any)

Syntax

mixed dbx_query (object $link_identifier, string $sql_statement, int $flags)

Arguments

  • link_identifier - The DBX link object returned by dbx_connect()
  • sql_statement - SQL statement. Data inside the query should be properly escaped.
  • flags - 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. DBX_RESULT_INDEX It is alwaysset, that is, the returned object has a dataproperty which is a 2 dimensional array indexed numerically. For example, in the expression data[2][3] 2stands for the row (or record) number and 3stands 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. DBX_RESULT_INFO It provides info about columns, such as field names and field types. DBX_RESULT_ASSOC It effects that the field values can be accessed with the respective column names used as keys to the returned object\'s dataproperty. 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. DBX_RESULT_UNBUFFERED This flag will not create the dataproperty, and the rowsproperty will initially be 0. Use this flag for large datasets, and use dbx_fetch_row() to retrieve the results row by row. The dbx_fetch_row() function will return rows that are conformant to the flags set with this query. Incidentally, it will also update the rowseach time it is called. DBX_COLNAMES_UNCHANGED The case of the returned column names will not be changed. DBX_COLNAMES_UPPERCASE The case of the returned column names will be changed to uppercase. DBX_COLNAMES_LOWERCASE The case of the returned column names will be changed to lowercase. Note that DBX_RESULT_INDEX is always used, regardless of the actual value of flags parameter. This means that only the following combinations are effective: DBX_RESULT_INDEX DBX_RESULT_INDEX | DBX_RESULT_INFO DBX_RESULT_INDEX | DBX_RESULT_INFO | DBX_RESULT_ASSOC - this is the default, if flags is not specified.

Description

Sends a query and fetch all results.

Version

PHP 4.0.6, 5 <= 5.0.5, PECL dbx >= 1.1.0

Return value

dbx_query() returns an object or 1on success, and 0on failure. The result object is returned only if the query given in sql_statement produces a result set (i.e. a SELECT query, even if the result set is empty).