PHP mysqli_options() Function
PHP mysqli_options() function sets extra connect options and affect behavior for a connection.
Syntax
bool mysqli_options(connection,option,value);
mysqli_options() Function Parameter
Parameter | Description |
connection : | Required parameter. The MySQL connection to be used |
option : | Required parameter. The option that you want to set. It can be one of the following values:
- MYSQLI_OPT_CONNECT_TIMEOUT - connection timout in seconds
- MYSQLI_OPT_LOCAL_INFILE - enable/disable use of LOAD LOCAL INFILE
- MYSQLI_INIT_COMMAND - command to execute after connecting to MySQL server
- MYSQLI_READ_DEFAULT_FILE - read options from named file instead of my.cnf
- MYSQLI_READ_DEFAULT_GROUP - read options from named group from my.cnf or the file specified in MYSQLI_READ_DEFAULT_FILE
- MYSQLI_SERVER_PUBLIC_KEY - RSA public key file used with SHA-256 based authentication
- MYSQLI_OPT_NET_CMD_BUFFER_SIZE - The size of the internal command/network buffer. Only valid for mysqlnd.
- MYSQLI_OPT_NET_READ_BUFFER_SIZE - Maximum read chunk size in bytes when reading the body of a MySQL command packet. Only valid for mysqlnd.
- MYSQLI_OPT_INT_AND_FLOAT_NATIVE - Convert integer and float columns back to PHP numbers. Only valid for mysqlnd.
- MYSQLI_OPT_SSL_VERIFY_SERVER_CERT
|
value : | Required parameter. The value for the option. |
mysqli_options() Function Return Value
Return Values : | Returns TRUE on success or FALSE on failure.
|
mysqli_options() Function Example
<?php
$con = mysqli_init();
mysqli_options($con,MYSQLI_READ_DEFAULT_FILE,"txtfile.txt");
if (!mysqli_real_connect($con,"localhost","user","password","db"))
{
die("Connect Error: " . mysqli_connect_error());
}
mysqli_close($con);
?>