Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

mysqli_options(3) [php man page]

MYSQLI_OPTIONS(3)							 1							 MYSQLI_OPTIONS(3)

mysqli::options - Set options

       Object oriented style

SYNOPSIS
bool mysqli::options (int $option, mixed $value) DESCRIPTION
Procedural style bool mysqli_options (mysqli $link, int $option, mixed $value) Used to set extra connect options and affect behavior for a connection. This function may be called multiple times to set several options. mysqli_options(3) should be called after mysqli_init(3) and before mysqli_real_connect(3). PARAMETERS
o $ link -Procedural style only: A link identifier returned by mysqli_connect(3) or mysqli_init(3) o $option - The option that you want to set. It can be one of the following values: Valid options +---------------------------+---------------------------------------------------+ | Name | | | | | | | Description | | | | +---------------------------+---------------------------------------------------+ | | | |MYSQLI_OPT_CONNECT_TIMEOUT | | | | | | | connection timeout in seconds (supported on Win- | | | dows with TCP/IP since PHP 5.3.1) | | | | | | | | MYSQLI_OPT_LOCAL_INFILE | | | | | | | enable/disable use of LOAD LOCAL INFILE | | | | | | | | MYSQLI_INIT_COMMAND | | | | | | | command to execute after when connecting to MySQL | | | server | | | | | | | | MYSQLI_READ_DEFAULT_FILE | | | | | | | Read options from named option file instead of | | | my.cnf | | | | | | | |MYSQLI_READ_DEFAULT_GROUP | | | | | | | Read options from the named group from my.cnf or | | | the file specified with MYSQL_READ_DEFAULT_FILE. | | | | | | | | MYSQLI_SERVER_PUBLIC_KEY | | | | | | | RSA public key file used with the SHA-256 based | | | authentication. | | | | +---------------------------+---------------------------------------------------+ o $value - The value for the option. RETURN VALUES
Returns TRUE on success or FALSE on failure. CHANGELOG
+--------+-------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+-------------------------------------------------+ | 5.5.0 | | | | | | | The MYSQLI_SERVER_PUBLIC_KEY option was added. | | | | +--------+-------------------------------------------------+ EXAMPLES
See mysqli_real_connect(3). NOTES
Note MySQLnd always assumes the server default charset. This charset is sent during connection hand-shake/authentication, which mysqlnd will use. Libmysqlclient uses the default charset set in the my.cnf or by an explicit call to mysqli_options(3) prior to calling mysqli_real_connect(3), but after mysqli_init(3). SEE ALSO
mysqli_init(3), mysqli_real_connect(3). PHP Documentation Group MYSQLI_OPTIONS(3)

Check Out this Related Man Page

MYSQLI_SELECT_DB(3)							 1						       MYSQLI_SELECT_DB(3)

mysqli::select_db - Selects the default database for database queries

       Object oriented style

SYNOPSIS
bool mysqli::select_db (string $dbname) DESCRIPTION
Procedural style bool mysqli_select_db (mysqli $link, string $dbname) Selects the default database to be used when performing queries against the database connection. Note This function should only be used to change the default database for the connection. You can select the default database with 4th parameter in mysqli_connect(3). PARAMETERS
o $ link -Procedural style only: A link identifier returned by mysqli_connect(3) or mysqli_init(3) o $dbname - The database name. RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #1 mysqli::select_db example Object oriented style <?php $mysqli = new mysqli("localhost", "my_user", "my_password", "test"); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s ", mysqli_connect_error()); exit(); } /* return name of current default database */ if ($result = $mysqli->query("SELECT DATABASE()")) { $row = $result->fetch_row(); printf("Default database is %s. ", $row[0]); $result->close(); } /* change db to world db */ $mysqli->select_db("world"); /* return name of current default database */ if ($result = $mysqli->query("SELECT DATABASE()")) { $row = $result->fetch_row(); printf("Default database is %s. ", $row[0]); $result->close(); } $mysqli->close(); ?> Procedural style <?php $link = mysqli_connect("localhost", "my_user", "my_password", "test"); /* check connection */ if (mysqli_connect_errno()) { printf("Connect failed: %s ", mysqli_connect_error()); exit(); } /* return name of current default database */ if ($result = mysqli_query($link, "SELECT DATABASE()")) { $row = mysqli_fetch_row($result); printf("Default database is %s. ", $row[0]); mysqli_free_result($result); } /* change db to world db */ mysqli_select_db($link, "world"); /* return name of current default database */ if ($result = mysqli_query($link, "SELECT DATABASE()")) { $row = mysqli_fetch_row($result); printf("Default database is %s. ", $row[0]); mysqli_free_result($result); } mysqli_close($link); ?> The above examples will output: Default database is test. Default database is world. SEE ALSO
mysqli_connect(3), mysqli_real_connect(3). PHP Documentation Group MYSQLI_SELECT_DB(3)
Man Page