Annotation of embedaddon/php/ext/mysqli/tests/mysqli_set_local_infile_handler_closures.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: mysqli_set_local_infile_handler() - use closures as handler
! 3: --SKIPIF--
! 4: <?php
! 5: require_once('skipif.inc');
! 6: require_once('skipifemb.inc');
! 7: require_once('skipifconnectfailure.inc');
! 8:
! 9: if (!function_exists('mysqli_set_local_infile_handler'))
! 10: die("skip - function not available.");
! 11:
! 12: require_once('connect.inc');
! 13: if (!$TEST_EXPERIMENTAL)
! 14: die("skip - experimental (= unsupported) feature");
! 15:
! 16: if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
! 17: die("skip Cannot connect to MySQL");
! 18:
! 19: include_once("local_infile_tools.inc");
! 20: if ($msg = check_local_infile_support($link, $engine))
! 21: die(sprintf("skip %s, [%d] %s", $msg, $link->errno, $link->error));
! 22:
! 23: mysqli_close($link);
! 24: ?>
! 25: --INI--
! 26: mysqli.allow_local_infile=1
! 27: --FILE--
! 28: <?php
! 29: require_once('connect.inc');
! 30: require_once('local_infile_tools.inc');
! 31: require_once('table.inc');
! 32:
! 33: $callback_replace_buffer = function ($fp, &$buffer, $buflen, &$error) {
! 34: static $invocation = 0;
! 35:
! 36: printf("Callback: %d\n", $invocation++);
! 37: flush();
! 38:
! 39: $buffer = fread($fp, $buflen);
! 40:
! 41: if ($invocation > 10)
! 42: return 0;
! 43:
! 44: return strlen($buffer);
! 45: };
! 46:
! 47: $file = create_standard_csv(1);
! 48: if (!try_handler(20, $link, $file, $callback_replace_buffer, null))
! 49: printf("[008] Failure\n");
! 50:
! 51: mysqli_close($link);
! 52: print "done!";
! 53: ?>
! 54: --CLEAN--
! 55: <?php
! 56: require_once("clean_table.inc");
! 57: ?>
! 58: --EXPECTF--
! 59: Callback set to 'Closure object'
! 60: Callback: 0
! 61: Callback: 1
! 62: done!
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>