Open a new connection to the MySQL server:
<?php$con=mysqli_init();if (!$con) { die("mysqli_init failed"); }mysqli_options($con,MYSQLI_READ_DEFAULT_FILE,"myfile.cnf");if (!mysqli_real_connect($con,"localhost ","my_user","my_password","my_db")) { die("Connection error: " . mysqli_connect_error()); }mysqli_close($con);?>The mysqli_options() function sets additional connection options that affect connection behavior.
The mysqli_options() function can be called several times to set several options.
Note: The mysqli_options() function can be called after mysqli_init() and before mysqli_real_connect().
mysqli_options( connection, option, value ) ;
parameter | describe |
---|---|
connection | Required. Specifies the MySQL connection to use. |
option | Required. Specifies the options to set. Can be one of the following values: MYSQLI_OPT_CONNECT_TIMEOUT - Connection timeout in seconds MYSQLI_OPT_LOCAL_INFILE - enable/disable LOAD LOCAL INFILE MYSQLI_INIT_COMMAND - command to execute after connecting to the MySQL server MYSQLI_READ_DEFAULT_FILE - option to read from a named file instead of my.cnf MYSQLI_READ_DEFAULT_GROUP - Read options from a named group in the file specified in my.cnf or MYSQLI_READ_DEFAULT_FILE MYSQLI_SERVER_PUBLIC_KEY - RSA public key file based on SHA-256 authentication |
value | Required. Specifies the value of option . |
Return value: | Returns TRUE if successful and FALSE if failed. |
---|---|
PHP version: | 5+ |
Update log: | The MYSQLI_SERVER_PUBLIC_KEY option was added in PHP 5.5. |