mysql_prepare()
mysql_param_count()
mysql_prepare_result()
mysql_bind_param()
mysql_execute()
mysql_stmt_affected_rows()
mysql_bind_result()
mysql_stmt_store_result()
mysql_stmt_data_seek()
mysql_stmt_row_seek()
mysql_stmt_row_tell()
mysql_stmt_num_rows()
mysql_fetch()
mysql_send_long_data()
mysql_stmt_close()
mysql_stmt_errno()
mysql_stmt_error()
mysql_stmt_sqlstate()
mysql_prepare()
MYSQL_STMT * mysql_prepare(MYSQL *mysql, const char *query, unsigned
long length)
Prepares the SQL query pointed to by the null-terminated string
query
, and returns a statement handle to be used for further operations
on the statement. The query must consist of a single SQL statement. You should
not add a terminating semicolon (`;') or \g
to the statement.
The application can include one or more parameter markers in the SQL statement by embedding question mark (`?') characters into the SQL string at the appropriate positions.
The markers are legal only in certain places in SQL statements. For
example, they are allowed in the VALUES()
list of an INSERT
statement (to specify column values for a row), or in a comparison with a
column in a WHERE
clause to specify a comparison value.
However, they are not allowed for identifiers (such as table or column
names), in the select list that names the columns to
be returned by a SELECT
statement), or to specify both
operands of a binary operator such as the =
equal sign.
The latter restriction is necessary because it
would be impossible to determine the parameter type. In general,
parameters are legal only in Data Manipulation Languange (DML)
statements, and not in Data Defination Language (DDL) statements.
The parameter markers must be bound to application variables using
mysql_bind_param()
before executing the statement.
A pointer to a MYSQL_STMT
structure if the prepare was successful.
NULL
if an error occurred.
CR_COMMANDS_OUT_OF_SYNC
CR_OUT_OF_MEMORY
CR_SERVER_GONE_ERROR
CR_SERVER_LOST
CR_UNKNOWN_ERROR
If the prepare is not successful (that is, mysql_prepare()
returns
NULL
), the error message can be obtained by calling
mysql_error()
.
For the usage of mysql_prepare()
, refer to the Example from
section 9.1.7.5 mysql_execute()
.