Annotation of embedaddon/php/ext/mysqli/tests/mysqli_set_local_infile_handler_close_link.phpt, revision 1.1.1.1

1.1       misho       1: --TEST--
                      2: mysqli_set_local_infile_handler() - close database link
                      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("table.inc");
                     30:        require_once('local_infile_tools.inc');
                     31: 
                     32:        function callback_close_link($fp, &$buffer, $buflen, &$error) {
                     33:                global $link;
                     34:                static $invocation = 0;
                     35: 
                     36:                printf("Callback: %d\n", $invocation++);
                     37:                flush();
                     38:                if (is_object($link))
                     39:                        mysqli_close($link);
                     40: 
                     41:                $buffer = "1;'a';\n";
                     42:                if ($invocation > 10)
                     43:                        return 0;
                     44: 
                     45:                return strlen($buffer);
                     46:        }
                     47: 
                     48:        $file = create_standard_csv(1);
                     49:        $expected = array(array('id' => 1, 'label' => 'a'));
                     50:        try_handler(20, $link, $file, 'callback_close_link', $expected);
                     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 'callback_close_link'
                     60: Callback: 0
                     61: done!

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>