П О Р Т А Л                            
С Е Т Е В Ы Х                          
П Р О Е К Т О В                        
Поиск по сайту:

О проекте

     HTML & JavaScript
     XML & XSLT
     Unix Shell





Самое читаемое:

Учебник PHP - "Для Чайника".
Просмотров 362 раз(а).

Иллюстрированный самоучитель по созданию сайтов.
Просмотров 93586 раз(а).

Учебник HTML.
Просмотров 81698 раз(а).

Руководство по PHP5.
Просмотров 52004 раз(а).

Хостинг через призму DNS.
Просмотров 60593 раз(а).

Подборка текстов стандартных документов.
Просмотров 50634 раз(а).

Учебник PHP - Самоучитель
Просмотров 57964 раз(а).

Документация на MySQL (учебник & справочное руководство)
Просмотров 59458 раз(а).

Внешние атаки...
Просмотров 49071 раз(а).

Учебник PHP.
Просмотров 42490 раз(а).

SSI в примерах.
Просмотров 32768 раз(а).

| Добавить в избранное | Сделать стартовой | Помощь

Руководство по PHP
Пред. След.


(PHP 4 >= 4.0.6, PHP 5 <= 5.0.4)

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


mixed dbx_query ( object link_identifier, string sql_statement [, int flags] )

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 (i.e. a SELECT query, even if the result set is empty).

Пример 1. How to handle the returned value

= dbx_connect(DBX_ODBC, "", "db", "username", "password")
    or die(
"Could not connect");

$result = dbx_query($link, 'SELECT id, parentid, description FROM table');

if (
is_object($result) ) {
// ... do some stuff here, see detailed examples below ...
    // first, print out field names and types
    // then, draw a table filled with the returned field values
} else {
"Query failed");


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.


This flag will not create the data property, and the rows property 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 rows each time it is called.

DBX_COLNAMES_UNCHANGED (available from PHP 4.3.0)

The case of the returned column names will not be changed.

DBX_COLNAMES_UPPERCASE (available from PHP 4.3.0)

The case of the returned column names will be changed to uppercase.

DBX_COLNAMES_LOWERCASE (available from PHP 4.3.0)

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_INFO | DBX_RESULT_ASSOC - this is the default, if flags is not specified.

The returned 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).

= dbx_query($link, "SELECT id FROM table");
mysql_field_len($result->handle, 0);

cols and rows

These contain the number of columns (or fields) and rows (or records) respectively.

= dbx_query($link, 'SELECT id FROM table');
$result->rows; // number of records
echo $result->cols; // number of fields

info (optional)

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.

Пример 2. lists each field's name and type

= dbx_query($link, 'SELECT id FROM table',

for (
$i = 0; $i < $result->cols; $i++ ) {
$result->info['name'][$i] . "\n";
$result->info['type'][$i] . "\n";  

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"].

Пример 3. outputs the content of data property into HTML table

= dbx_query($link, 'SELECT id, parentid, description FROM table');

foreach (
$result->data as $row) {
    foreach (
$row as $field) {

Пример 4. How to handle UNBUFFERED queries


= dbx_query ($link, 'SELECT id, parentid, description FROM table', DBX_RESULT_UNBUFFERED);

while (
$row = dbx_fetch_row($result)) {
    foreach (
$row as $field) {


Замечание: 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(), dbx_fetch_row() and dbx_connect().

Если Вы не нашли что искали, то рекомендую воспользоваться поиском по сайту:

Copyright © 2005-2016 Project.Net.Ru