6.2 C API Prepared Statement Data Structures (original) (raw)

MYSQL_STMT

This structure is a handler for a prepared statement. A handler is created by callingmysql_stmt_init(), which returns a pointer to a MYSQL_STMT. The handler is used for all subsequent operations with the statement until you close it withmysql_stmt_close(), at which point the handler becomes invalid and should no longer be used.

The MYSQL_STMT structure has no members intended for application use. Applications should not try to copy a MYSQL_STMT structure. There is no guarantee that such a copy will be usable.

Multiple statement handlers can be associated with a single connection. The limit on the number of handlers depends on the available system resources.

MYSQL_BIND

This structure is used both for statement input (data values sent to the server) and output (result values returned from the server):

To use a MYSQL_BIND structure, zero its contents to initialize it, then set its members appropriately. For example, to declare and initialize an array of threeMYSQL_BIND structures, use this code:

MYSQL_BIND bind[3];
memset(bind, 0, sizeof(bind));

The MYSQL_BIND structure contains the following members for use by application programs. For several of the members, the manner of use depends on whether the structure is used for input or output.

MYSQL_TIME

This structure is used to send and receiveDATE,TIME,DATETIME, andTIMESTAMP data directly to and from the server. Set the buffer member to point to a MYSQL_TIME structure, and set the buffer_type member of aMYSQL_BIND structure to one of the temporal types (MYSQL_TYPE_TIME,MYSQL_TYPE_DATE,MYSQL_TYPE_DATETIME,MYSQL_TYPE_TIMESTAMP).

The MYSQL_TIME structure contains the members listed in the following table.

Member Description
unsigned int year The year
unsigned int month The month of the year
unsigned int day The day of the month
unsigned int hour The hour of the day
unsigned int minute The minute of the hour
unsigned int second The second of the minute
bool neg A boolean flag indicating whether the time is negative
unsigned long second_part The fractional part of the second in microseconds

Only those parts of a MYSQL_TIME structure that apply to a given type of temporal value are used. Theyear, month, andday elements are used forDATE,DATETIME, andTIMESTAMP values. Thehour, minute, andsecond elements are used forTIME,DATETIME, andTIMESTAMP values. SeeSection 3.6.4, “Prepared Statement Handling of Date and Time Values”.