Oracle 5.0 Reference Manual page 2162

Table of Contents

Advertisement

Function
mysql_store_result()
mysql_thread_end()
mysql_thread_id()
mysql_thread_init()
mysql_thread_safe()
mysql_use_result()
mysql_warning_count()
Application programs should use this general outline for interacting with MySQL:
1. Initialize the MySQL library by calling mysql_library_init(). This function exists in both the
libmysqlclient
whether you build a regular client program by linking with the
embedded server application by linking with the
2. Initialize a connection handler by calling
mysql_real_connect().
3. Issue SQL statements and process their results. (The following discussion provides more
information about how to do this.)
4. Close the connection to the MySQL server by calling mysql_close().
5. End use of the MySQL library by calling mysql_library_end().
The purpose of calling
initialization and finalization of the MySQL library. For applications that are linked with the client library,
they provide improved memory management. If you don't call mysql_library_end(), a block of
memory remains allocated. (This does not increase the amount of memory used by the application, but
some memory leak detectors will complain about it.) For applications that are linked with the embedded
server, these calls start and stop the server.
mysql_library_init()
versions of MySQL, you can call
In a nonmulti-threaded environment, the call to
will invoke it automatically as necessary. However,
mysql_init()
not thread-safe in a multi-threaded environment, and thus neither is mysql_init(), which calls
mysql_library_init(). You must either call
threads, or else use a mutex to protect the call, whether you invoke
indirectly through mysql_init(). This should be done prior to any other client library call.
To connect to the server, call
mysql_real_connect()
user name, and password). Upon connection,
(part of the
structure) to a value of
MYSQL
versions. A value of
for this flag indicates that if a statement cannot be performed because of a lost
1
connection, to try reconnecting to the server before giving up. As of MySQL 5.0.13, you can use the
MYSQL_OPT_RECONNECT
are done with the connection, call
While a connection is active, the client may send SQL statements to the server using
or mysql_real_query(). The difference between the two is that
to be specified as a null-terminated string whereas
the string contains binary data (which may include null bytes), you must use mysql_real_query().
C API Function Overview
Description
Retrieves a complete result set to the client
Finalize thread handler
Returns the current thread ID
Initialize thread handler
Returns 1 if the clients are compiled as thread-safe
Initiates a row-by-row result set retrieval
Returns the warning count for the previous SQL statement
C client library and the
mysql_init()
mysql_library_init()
and
mysql_library_end()
mysql_server_init()
mysql_init()
with that handler (along with other information such as the host name,
in versions of the API older than 5.0.3, or
1
option to
mysql_options()
mysql_close()
2142
embedded server library, so it is used
libmysqld
-libmysqlclient
flag.
-libmysqld
and connect to the server by calling
and
mysql_library_end()
are available as of MySQL 5.0.3. For older
and
mysql_server_end()
mysql_library_init()
mysql_library_init()
mysql_library_init()
mysql_library_init()
to initialize a connection handler, then call
mysql_real_connect()
to control reconnection behavior. When you
to terminate it.
mysql_query()
mysql_real_query()
flag, or an
is to provide proper
instead.
may be omitted, because
is
prior to spawning any
or
sets the
flag
reconnect
in newer
0
mysql_query()
expects the query
expects a counted string. If

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents