From 50aba4e9e38478a32fcaebeb13c1eba7a709d442 Mon Sep 17 00:00:00 2001 From: Hartmut Holzgraefe Date: Sun, 13 Jan 2008 00:45:06 +0000 Subject: [PATCH] documentation for mysqli_set_local_infile_handler added git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@250511 c90b9560-bf6c-de11-be94-00142212c4b1 --- .../mysqli/set-local-infile-handler.xml | 169 +++++++++++++++++- 1 file changed, 166 insertions(+), 3 deletions(-) diff --git a/reference/mysqli/mysqli/set-local-infile-handler.xml b/reference/mysqli/mysqli/set-local-infile-handler.xml index 2d3a071db6..c6344bfcce 100644 --- a/reference/mysqli/mysqli/set-local-infile-handler.xml +++ b/reference/mysqli/mysqli/set-local-infile-handler.xml @@ -1,10 +1,10 @@ - + mysqli::set_local_infile_handler mysqli_set_local_infile_handler - Set callback functions for LOAD DATA LOCAL INFILE command + Set callback function for LOAD DATA LOCAL INFILE command @@ -14,9 +14,172 @@ mysqlilink callbackread_func + Object oriented style (method) + + mysqli + + boolset_local_infile_handler + mysqlilink + callbackread_func + + + + Set callback function for LOAD DATA LOCAL INFILE command - &warn.undocumented.func; + + 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 speficied in the + LOAD DATA + + + + + &reftitle.parameters; + + + &mysqli.link.description; + + read_func + + + A callback function or object method taking the following parameters: + + + + stream + A PHP stream associated with the SQL commands INFILE + + + &buffer + A string buffer to store the rewritten input into + + + buflen + The maximum number of characters to be stored in the buffer + + + &errormsg + If an error occures 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 + occured. + + + + + &reftitle.returnvalues; + + &return.success; + + + + + &reftitle.examples; + + Object oriented style + +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(",", "\t", $buffer)); + + return strlen($buffer); + } + + $db->set_local_infile_handler("callme"); + + echo "Input:\n"; + + $db->query("LOAD DATA LOCAL INFILE 'input.txt' INTO TABLE t1"); + + $res = $db->query("SELECT * FROM t1"); + + echo "\nResult:\n"; + while ($row = $res->fetch_assoc()) { + echo join(",", $row)."\n"; + } +?> +]]> + + + + Procedural style + + +]]> + + + &example.outputs; + + + + + + + &reftitle.seealso; + + + mysqli_set_local_infile_default + +