php-src/ext/mysqli/tests/mysqli_set_local_infile_handler_unregister.phpt

65 lines
1.5 KiB
Plaintext
Raw Normal View History

2007-10-10 10:18:50 +00:00
--TEST--
mysqli_set_local_infile_handler() - do not use the file pointer
--SKIPIF--
<?php
require_once('skipif.inc');
require_once('skipifemb.inc');
require_once('skipifconnectfailure.inc');
if (!function_exists('mysqli_set_local_infile_handler'))
die("skip - function not available.");
require_once('connect.inc');
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
2007-10-10 10:18:50 +00:00
die("skip Cannot connect to MySQL");
include_once("local_infile_tools.inc");
if ($msg = check_local_infile_support($link, $engine))
die(sprintf("skip %s, [%d] %s", $msg, $link->errno, $link->error));
2007-10-10 10:18:50 +00:00
mysqli_close($link);
?>
--INI--
mysqli.allow_local_infile=1
--FILE--
<?php
require_once('connect.inc');
require_once('local_infile_tools.inc');
require_once('table.inc');
function callback_unregister($fp, &$buffer, $buflen, &$error) {
global $link;
static $invocation = 0;
printf("Callback: %d\n", $invocation++);
flush();
if (is_resource($fp))
fclose($fp);
$buffer = "1;'a';\n";
if ($invocation > 10)
return 0;
mysqli_set_local_infile_default($link);
return strlen($buffer);
}
$file = create_standard_csv(1);
$expected = array(array('id' => 1, 'label' => 'a'));
try_handler(20, $link, $file, 'callback_unregister', $expected);
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
require_once("clean_table.inc");
?>
2007-10-10 10:18:50 +00:00
--EXPECTF--
Callback set to 'callback_unregister'
Callback: 0
Warning: mysqli_query(): File handle closed in %s on line %d
[022] LOAD DATA failed, [2000] File handle closed
[024/0] [0] ''
done!