![background image](http://html1.mh-extra.com/html/oracle/5-0/5-0_reference-manual_16461962175.webp)
C API Function Descriptions
2155
mysql_use_result()
,
mysql_fetch_row()
returns
NULL
when there are no more rows to retrieve
or if an error occurred.
The number of values in the row is given by
mysql_num_fields(result)
. If
row
holds the
return value from a call to
mysql_fetch_row()
, pointers to the values are accessed as
row[0]
to
row[mysql_num_fields(result)-1]
.
NULL
values in the row are indicated by
NULL
pointers.
The lengths of the field values in the row may be obtained by calling
mysql_fetch_lengths()
.
Empty fields and fields containing
NULL
both have length 0; you can distinguish these by checking the
pointer for the field value. If the pointer is
NULL
, the field is
NULL
; otherwise, the field is empty.
Return Values
A
MYSQL_ROW
structure for the next row.
NULL
if there are no more rows to retrieve or if an error
occurred.
Errors
Note that error is not reset between calls to
mysql_fetch_row()
•
CR_SERVER_LOST
[2942]
The connection to the server was lost during the query.
•
CR_UNKNOWN_ERROR
[2941]
An unknown error occurred.
Example
MYSQL_ROW row;
unsigned int num_fields;
unsigned int i;
num_fields = mysql_num_fields(result);
while ((row = mysql_fetch_row(result)))
{
unsigned long *lengths;
lengths = mysql_fetch_lengths(result);
for(i = 0; i < num_fields; i++)
{
printf("[%.*s] ", (int) lengths[i],
row[i] ? row[i] : "NULL");
}
printf("\n");
}
20.6.6.22.
mysql_field_count()
unsigned int mysql_field_count(MYSQL *mysql)
Description
Returns the number of columns for the most recent query on the connection.
The normal use of this function is when
mysql_store_result()
returned
NULL
(and thus you
have no result set pointer). In this case, you can call
mysql_field_count()
to determine whether
mysql_store_result()
should have produced a nonempty result. This enables the client program
to take proper action without knowing whether the query was a
SELECT
(or
SELECT
-like) statement.
The example shown here illustrates how this may be done.
See
Section 20.6.13.1, “Why
mysql_store_result()
Sometimes Returns
NULL
After
mysql_query()
Returns Success”
.
Содержание 5.0
Страница 1: ...MySQL 5 0 Reference Manual ...
Страница 18: ...xviii ...
Страница 60: ...40 ...
Страница 396: ...376 ...
Страница 578: ...558 ...
Страница 636: ...616 ...
Страница 844: ...824 ...
Страница 1234: ...1214 ...
Страница 1426: ...MySQL Proxy Scripting 1406 The following diagram shows an overview of the classes exposed by MySQL Proxy ...
Страница 1427: ...MySQL Proxy Scripting 1407 ...
Страница 1734: ...1714 ...
Страница 1752: ...1732 ...
Страница 1783: ...Configuring Connector ODBC 1763 ...
Страница 1793: ...Connector ODBC Examples 1773 ...
Страница 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Страница 1842: ...Connector Net Installation 1822 5 Once the installation has been completed click Finish to exit the installer ...
Страница 1864: ...Connector Net Visual Studio Integration 1844 Figure 20 24 Debug Stepping Figure 20 25 Function Stepping 1 of 2 ...
Страница 2850: ...2830 ...
Страница 2854: ...2834 ...
Страница 2928: ...2908 ...
Страница 3000: ...2980 ...
Страница 3122: ...3102 ...
Страница 3126: ...3106 ...
Страница 3174: ...3154 ...
Страница 3232: ...3212 ...