diff options
author | Georg Richter <georg@php.net> | 2004-08-25 13:58:03 +0000 |
---|---|---|
committer | Georg Richter <georg@php.net> | 2004-08-25 13:58:03 +0000 |
commit | 616d49aaf6b3a09d946cd732b07b1c27bbe85942 (patch) | |
tree | 2ac0b98b37068f771ba03a010408998826ea6f6b /ext | |
parent | c8572b0bba9264d9357bc556c07000d913cf0259 (diff) | |
download | php-git-616d49aaf6b3a09d946cd732b07b1c27bbe85942.tar.gz |
test for local_infile_handler
Diffstat (limited to 'ext')
-rw-r--r-- | ext/mysqli/tests/061.phpt | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/ext/mysqli/tests/061.phpt b/ext/mysqli/tests/061.phpt new file mode 100644 index 0000000000..438f4a203a --- /dev/null +++ b/ext/mysqli/tests/061.phpt @@ -0,0 +1,39 @@ +--TEST-- +local infile handler +--FILE-- +<?php + include "connect.inc"; + + function my_read($fp, &$buffer, $buflen, &$error) { + $buffer = strrev(fread($fp, $buflen)); + return(strlen($buffer)); + } + + /*** test mysqli_connect 127.0.0.1 ***/ + $link = mysqli_connect("localhost", $user, $passwd, "test"); + + /* create temporary file */ + $fp = fopen("061.csv", "w"); + fwrite($fp, "foo;bar"); + fclose($fp); + + mysqli_query($link,"DROP TABLE IF EXISTS t_061"); + mysqli_query($link,"CREATE TABLE t_061 (c1 varchar(10), c2 varchar(10))"); + + mysqli_query($link, "LOAD DATA LOCAL INFILE '061.csv' INTO TABLE t_061 FIELDS TERMINATED BY ';'"); + + mysqli_set_local_infile_handler($link, "my_read"); + mysqli_query($link, "LOAD DATA LOCAL INFILE '061.csv' INTO TABLE t_061 FIELDS TERMINATED BY ';'"); + + if ($result = mysqli_query($link, "SELECT c1,c2 FROM t_061")) { + while (($row = mysqli_fetch_row($result))) { + printf("%s-%s\n", $row[0], $row[1]); + } + mysqli_free_result($result); + } + + mysqli_close($link); +?> +--EXPECT-- +foo-bar +rab-oof |