MySQL :: MySQL 8.4 C API Developer Guide :: 5.4.55 mysql_options4() (original) (raw)

5.4.55 mysql_options4()

int
mysql_options4(MYSQL *mysql,
               enum mysql_option option,
               const void *arg1,
               const void *arg2)

Description

mysql_options4() is similar tomysql_options() but has an extra fourth argument so that two values can be passed for the option specified in the second argument.

The following list describes the permitted options, their effect, and how arg1 andarg2 are used.

Return Values

Zero for success. Nonzero if you specify an unknown option.

Errors

Example

This example demonstrates the calls that specify connection attributes:

MYSQL mysql;

mysql_init(&mysql);
mysql_options(&mysql,MYSQL_OPT_CONNECT_ATTR_RESET, 0);
mysql_options4(&mysql,MYSQL_OPT_CONNECT_ATTR_ADD, "key1", "value1");
mysql_options4(&mysql,MYSQL_OPT_CONNECT_ATTR_ADD, "key2", "value2");
mysql_options4(&mysql,MYSQL_OPT_CONNECT_ATTR_ADD, "key3", "value3");
mysql_options(&mysql,MYSQL_OPT_CONNECT_ATTR_DELETE, "key1");
if (!mysql_real_connect(&mysql,"host","user","passwd","database",0,NULL,0))
{
    fprintf(stderr, "Failed to connect to database: Error: %s\n",
        mysql_error(&mysql));
}