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_SET_LOCAL_INFILE_HANDLER(3)					 1					MYSQLI_SET_LOCAL_INFILE_HANDLER(3)

mysqli::set_local_infile_handler - Set callback function for LOAD DATA LOCAL INFILE command

       Object oriented style

SYNOPSIS
bool mysqli::set_local_infile_handler (mysqli $link, callable $read_func) DESCRIPTION
Procedural style bool mysqli_set_local_infile_handler (mysqli $link, callable $read_func) Set callback function for LOAD DATA LOCAL INFILE command The callbacks task is to read input from the file specified in the LOAD DATA LOCAL INFILE and to reformat it into the format understood by LOAD DATA INFILE. The returned data needs to match the format specified in the LOAD DATA PARAMETERS
o $ link -Procedural style only: A link identifier returned by mysqli_connect(3) or mysqli_init(3) o $read_func - A callback function or object method taking the following parameters: o $stream -A PHP stream associated with the SQL commands INFILE o $&buffer -A string buffer to store the rewritten input into o $buflen -The maximum number of characters to be stored in the buffer o $&errormsg -If an error occurs you can store an error message in here The callback function should return the number of characters stored in the $buffer or a negative value if an error occurred. RETURN VALUES
Returns TRUE on success or FALSE on failure. EXAMPLES
Example #1 mysqli::set_local_infile_handler example Object oriented style <?php $db = mysqli_init(); $db->real_connect("localhost","root","","test"); function callme($stream, &$buffer, $buflen, &$errmsg) { $buffer = fgets($stream); echo $buffer; // convert to upper case and replace "," delimiter with [TAB] $buffer = strtoupper(str_replace(",", " ", $buffer)); return strlen($buffer); } echo "Input: "; $db->set_local_infile_handler("callme"); $db->query("LOAD DATA LOCAL INFILE 'input.txt' INTO TABLE t1"); $db->set_local_infile_default(); $res = $db->query("SELECT * FROM t1"); echo " Result: "; while ($row = $res->fetch_assoc()) { echo join(",", $row)." "; } ?> Procedural style <?php $db = mysqli_init(); mysqli_real_connect($db, "localhost","root","","test"); function callme($stream, &$buffer, $buflen, &$errmsg) { $buffer = fgets($stream); echo $buffer; // convert to upper case and replace "," delimiter with [TAB] $buffer = strtoupper(str_replace(",", " ", $buffer)); return strlen($buffer); } echo "Input: "; mysqli_set_local_infile_handler($db, "callme"); mysqli_query($db, "LOAD DATA LOCAL INFILE 'input.txt' INTO TABLE t1"); mysqli_set_local_infile_default($db); $res = mysqli_query($db, "SELECT * FROM t1"); echo " Result: "; while ($row = mysqli_fetch_assoc($res)) { echo join(",", $row)." "; } ?> The above examples will output: Input: 23,foo 42,bar Output: 23,FOO 42,BAR SEE ALSO
mysqli_set_local_infile_default(3). PHP Documentation Group MYSQLI_SET_LOCAL_INFILE_HANDLER(3)
Man Page