mysqli::options
(mysqli_options) Setting options
options()
/ mysqli_options()
function is used to set additional connection options and affect the behavior of the connection.
Note: This function should be called after init()
and before real_connect()
.
Set additional connection options:
<?php $mysqli = mysqli_init ( ) ; if ( ! $mysqli ) { die ( "mysqli_init failed" ) ; } // Specify the connection timeout $con -> options ( MYSQLI_OPT_CONNECT_TIMEOUT , 10 ) ; // Specify the option to read from named files instead of my.cnf $con -> options ( MYSQLI_READ_DEFAULT_FILE , "myfile.cnf" ) ; $con -> real_connect ( "localhost" , "my_user" , "my_password" , "my_db" ) ; ?>
Set additional connection options:
<?php $con = mysqli_init ( ) ; if ( ! $con ) { die ( "mysqli_init failed" ) ; } // Specify the connection timeout mysqli_options ( $con , MYSQLI_OPT_CONNECT_TIMEOUT , 10 ) ; // Specify the option to read from named files instead of my.cnf mysqli_options ( $con , MYSQLI_READ_DEFAULT_FILE , "myfile.cnf" ) ; mysqli_real_connect ( $con , "localhost" , "my_user" , "my_password" , "my_db" ) ; ?>