mysql 5.1.69_MySQL 5.1 英文手册 :: 21.9.3.69 mysql_store_result()

21.9.3.69. mysql_store_result()

MYSQL_RES *mysql_store_result(MYSQL *mysql)

Description

After invoking mysql_query() or

mysql_real_query(), you must

call mysql_store_result() or

mysql_use_result() for every

statement that successfully produces a result set

(SELECT,

SHOW,

DESCRIBE,

EXPLAIN,

CHECK TABLE, and so forth). You

must also call

mysql_free_result() after you

are done with the result set.

You don't have to call

mysql_store_result() or

mysql_use_result() for other

statements, but it does not do any harm or cause any notable

performance degradation if you call

mysql_store_result() in all

cases. You can detect whether the statement has a result set by

checking whether

mysql_store_result() returns a

nonzero value (more about this later on).

If you enable multiple-statement support, you should retrieve

results from calls to

mysql_query() or

mysql_real_query() by using a

loop that calls

mysql_next_result() to determine

whether there are more results. For an example, see

Section 21.9.12, “C API Support for Multiple Statement Execution”.

If you want to know whether a statement should return a result

set, you can use

mysql_field_count() to check for

this. See Section 21.9.3.22, “mysql_field_count()”.

mysql_store_result() reads the

entire result of a query to the client, allocates a

MYSQL_RES structure, and places the result

into this structure.

mysql_store_result() returns a

null pointer if the statement didn't return a result set (for

example, if it was an INSERT

statement).

mysql_store_result() also

returns a null pointer if reading of the result set failed. You

can check whether an error occurred by checking whether

mysql_error() returns a nonempty

string, mysql_errno() returns

nonzero, or mysql_field_count()

returns zero.

An empty result set is returned if there are no rows returned.

(An empty result set differs from a null pointer as a return

value.)

After you have called

mysql_store_result() and gotten

back a result that isn't a null pointer, you can call

mysql_num_rows() to find out how

many rows are in the result set.

You can call mysql_fetch_row()

to fetch rows from the result set, or

mysql_row_seek() and

mysql_row_tell() to obtain or

set the current row position within the result set.

Return Values

A MYSQL_RES result structure with the

results. NULL (0) if an error occurred.

Errors

Commands were executed in an improper order.

The MySQL server has gone away.

The connection to the server was lost during the query.

An unknown error occurred.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值