MYSQL官方免费手册中有很多说明和例子。20.9.2. C API Function Overview The functions available in the C API are summarized here and described in greater detail in a later section. See Section 20.9.3, “C API Function Descriptions”. Function Description my_init() Initialize global variables, and thread handler in thread-safe programs mysql_affected_rows() Returns the number of rows changed/deleted/inserted by the last UPDATE, DELETE, or INSERT query mysql_autocommit() Toggles autocommit mode on/off mysql_change_user() Changes user and database on an open connection mysql_character_set_name() Return default character set name for current connection mysql_close() Closes a server connection mysql_commit() Commits the transaction mysql_connect() Connects to a MySQL server (this function is deprecated; use mysql_real_connect() instead) mysql_create_db() Creates a database (this function is deprecated; use the SQL statement CREATE DATABASE instead) mysql_data_seek() Seeks to an arbitrary row number in a query result set mysql_debug() Does a DBUG_PUSH with the given string mysql_drop_db() Drops a database (this function is deprecated; use the SQL statement DROP DATABASE instead) mysql_dump_debug_info() Makes the server write debug information to the log mysql_eof() Determines whether the last row of a result set has been read (this function is deprecated; mysql_errno() or mysql_error() may be used instead) mysql_errno() Returns the error number for the most recently invoked MySQL function mysql_error() Returns the error message for the most recently invoked MySQL function mysql_escape_string() Escapes special characters in a string for use in an SQL statement mysql_fetch_field() Returns the type of the next table field mysql_fetch_field_direct() Returns the type of a table field, given a field number mysql_fetch_fields() Returns an array of all field structures mysql_fetch_lengths() Returns the lengths of all columns in the current row mysql_fetch_row() Fetches the next row from the result set mysql_field_count() Returns the number of result columns for the most recent statement mysql_field_seek() Puts the column cursor on a specified column mysql_field_tell() Returns the position of the field cursor used for the last mysql_fetch_field() mysql_free_result() Frees memory used by a result set mysql_get_character_set_info() Return information about default character set mysql_get_client_info() Returns client version information as a string mysql_get_client_version() Returns client version information as an integer mysql_get_host_info() Returns a string describing the connection mysql_get_proto_info() Returns the protocol version used by the connection mysql_get_server_info() Returns the server version number mysql_get_server_version() Returns version number of server as an integer mysql_get_ssl_cipher() Return current SSL cipher mysql_hex_string() Encode string in hexadecimal format mysql_info() Returns information about the most recently executed query mysql_init() Gets or initializes a MYSQL structure mysql_insert_id() Returns the ID generated for an AUTO_INCREMENT column by the previous query mysql_kill() Kills a given thread mysql_library_end() Finalize the MySQL C API library mysql_library_init() Initialize the MySQL C API library mysql_list_dbs() Returns database names matching a simple regular expression mysql_list_fields() Returns field names matching a simple regular expression mysql_list_processes() Returns a list of the current server threads mysql_list_tables() Returns table names matching a simple regular expression mysql_more_results() Checks whether any more results exist mysql_next_result() Returns/initiates the next result in multiple-result executions mysql_num_fields() Returns the number of columns in a result set mysql_num_rows() Returns the number of rows in a result set mysql_options() Sets connect options for mysql_real_connect() mysql_ping() Checks whether the connection to the server is working, reconnecting as necessary mysql_query() Executes an SQL query specified as a null-terminated string mysql_real_connect() Connects to a MySQL server mysql_real_escape_string() Escapes special characters in a string for use in an SQL statement, taking into account the current character set of the connection mysql_real_query() Executes an SQL query specified as a counted string mysql_refresh() Flush or reset tables and caches mysql_reload() Tells the server to reload the grant tables mysql_rollback() Rolls back the transaction mysql_row_seek() Seeks to a row offset in a result set, using value returned from mysql_row_tell() mysql_row_tell() Returns the row cursor position mysql_select_db() Selects a database mysql_server_end() Finalize the MySQL C API library mysql_server_init() Initialize the MySQL C API library mysql_set_character_set() Set default character set for current connection mysql_set_local_infile_default() Set the LOAD DATA LOCAL INFILE handler callbacks to their default values mysql_set_local_infile_handler() Install application-specific LOAD DATA LOCAL INFILE handler callbacks mysql_set_server_option() Sets an option for the connection (like multi-statements) mysql_sqlstate() Returns the SQLSTATE error code for the last error mysql_shutdown() Shuts down the database server mysql_ssl_set() Prepare to establish SSL connection to server mysql_stat() Returns the server status as a string mysql_store_result() Retrieves a complete result set to the client mysql_thread_end() Finalize thread handler mysql_thread_id() Returns the current thread ID mysql_thread_init() Initialize thread handler mysql_thread_safe() Returns 1 if the clients are compiled as thread-safe mysql_use_result() Initiates a row-by-row result set retrieval mysql_warning_count() Returns the warning count for the previous SQL statement Application programs should use this general outline for interacting with MySQL: Initialize the MySQL library by calling mysql_library_init(). This function exists in both the mysqlclient C client library and the mysqld embedded server library, so it is used whether you build a regular client program by linking with the -libmysqlclient flag, or an embedded server application by linking with the -libmysqld flag. Initialize a connection handler by calling mysql_init() and connect to the server by calling mysql_real_connect(). Issue SQL statements and process their results. (The following discussion provides more information about how to do this.) Close the connection to the MySQL server by calling mysql_close(). End use of the MySQL library by calling mysql_library_end(). The purpose of calling mysql_library_init() and mysql_library_end() is to provide proper 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.) Fo
mysql C++
The functions available in the C API are summarized here and described in greater detail in a later section. See Section 20.9.3, “C API Function Descriptions”. Function Description
my_init() Initialize global variables, and thread handler in thread-safe programs
mysql_affected_rows() Returns the number of rows changed/deleted/inserted by the last UPDATE, DELETE, or INSERT query
mysql_autocommit() Toggles autocommit mode on/off
mysql_change_user() Changes user and database on an open connection
mysql_character_set_name() Return default character set name for current connection
mysql_close() Closes a server connection
mysql_commit() Commits the transaction
mysql_connect() Connects to a MySQL server (this function is deprecated; use mysql_real_connect() instead)
mysql_create_db() Creates a database (this function is deprecated; use the SQL statement CREATE DATABASE instead)
mysql_data_seek() Seeks to an arbitrary row number in a query result set
mysql_debug() Does a DBUG_PUSH with the given string
mysql_drop_db() Drops a database (this function is deprecated; use the SQL statement DROP DATABASE instead)
mysql_dump_debug_info() Makes the server write debug information to the log
mysql_eof() Determines whether the last row of a result set has been read (this function is deprecated; mysql_errno() or mysql_error() may be used instead)
mysql_errno() Returns the error number for the most recently invoked MySQL function
mysql_error() Returns the error message for the most recently invoked MySQL function
mysql_escape_string() Escapes special characters in a string for use in an SQL statement
mysql_fetch_field() Returns the type of the next table field
mysql_fetch_field_direct() Returns the type of a table field, given a field number
mysql_fetch_fields() Returns an array of all field structures
mysql_fetch_lengths() Returns the lengths of all columns in the current row
mysql_fetch_row() Fetches the next row from the result set
mysql_field_count() Returns the number of result columns for the most recent statement
mysql_field_seek() Puts the column cursor on a specified column
mysql_field_tell() Returns the position of the field cursor used for the last mysql_fetch_field()
mysql_free_result() Frees memory used by a result set
mysql_get_character_set_info() Return information about default character set
mysql_get_client_info() Returns client version information as a string
mysql_get_client_version() Returns client version information as an integer
mysql_get_host_info() Returns a string describing the connection
mysql_get_proto_info() Returns the protocol version used by the connection
mysql_get_server_info() Returns the server version number
mysql_get_server_version() Returns version number of server as an integer
mysql_get_ssl_cipher() Return current SSL cipher
mysql_hex_string() Encode string in hexadecimal format
mysql_info() Returns information about the most recently executed query
mysql_init() Gets or initializes a MYSQL structure
mysql_insert_id() Returns the ID generated for an AUTO_INCREMENT column by the previous query
mysql_kill() Kills a given thread
mysql_library_end() Finalize the MySQL C API library
mysql_library_init() Initialize the MySQL C API library
mysql_list_dbs() Returns database names matching a simple regular expression
mysql_list_fields() Returns field names matching a simple regular expression
mysql_list_processes() Returns a list of the current server threads
mysql_list_tables() Returns table names matching a simple regular expression
mysql_more_results() Checks whether any more results exist
mysql_next_result() Returns/initiates the next result in multiple-result executions
mysql_num_fields() Returns the number of columns in a result set
mysql_num_rows() Returns the number of rows in a result set
mysql_options() Sets connect options for mysql_real_connect()
mysql_ping() Checks whether the connection to the server is working, reconnecting as necessary
mysql_query() Executes an SQL query specified as a null-terminated string
mysql_real_connect() Connects to a MySQL server
mysql_real_escape_string() Escapes special characters in a string for use in an SQL statement, taking into account the current character set of the connection
mysql_real_query() Executes an SQL query specified as a counted string
mysql_refresh() Flush or reset tables and caches
mysql_reload() Tells the server to reload the grant tables
mysql_rollback() Rolls back the transaction
mysql_row_seek() Seeks to a row offset in a result set, using value returned from mysql_row_tell()
mysql_row_tell() Returns the row cursor position
mysql_select_db() Selects a database
mysql_server_end() Finalize the MySQL C API library
mysql_server_init() Initialize the MySQL C API library
mysql_set_character_set() Set default character set for current connection
mysql_set_local_infile_default() Set the LOAD DATA LOCAL INFILE handler callbacks to their default values
mysql_set_local_infile_handler() Install application-specific LOAD DATA LOCAL INFILE handler callbacks
mysql_set_server_option() Sets an option for the connection (like multi-statements)
mysql_sqlstate() Returns the SQLSTATE error code for the last error
mysql_shutdown() Shuts down the database server
mysql_ssl_set() Prepare to establish SSL connection to server
mysql_stat() Returns the server status as a string
mysql_store_result() Retrieves a complete result set to the client
mysql_thread_end() Finalize thread handler
mysql_thread_id() Returns the current thread ID
mysql_thread_init() Initialize thread handler
mysql_thread_safe() Returns 1 if the clients are compiled as thread-safe
mysql_use_result() Initiates a row-by-row result set retrieval
mysql_warning_count() Returns the warning count for the previous SQL statement Application programs should use this general outline for interacting with MySQL: Initialize the MySQL library by calling mysql_library_init(). This function exists in both the mysqlclient C client library and the mysqld embedded server library, so it is used whether you build a regular client program by linking with the -libmysqlclient flag, or an embedded server application by linking with the -libmysqld flag. Initialize a connection handler by calling mysql_init() and connect to the server by calling mysql_real_connect(). Issue SQL statements and process their results. (The following discussion provides more information about how to do this.) Close the connection to the MySQL server by calling mysql_close(). End use of the MySQL library by calling mysql_library_end(). The purpose of calling mysql_library_init() and mysql_library_end() is to provide proper 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.) Fo
http://blog.csdn.net/iihero/article/details/8362269
mysql++ 和 mysql C API 比有什么弊端吗?