Annotation of embedaddon/php/ext/mysqli/tests/mysqli_info.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: mysqli_info()
! 3: --SKIPIF--
! 4: <?php
! 5: require_once('skipif.inc');
! 6: require_once('skipifemb.inc');
! 7: require_once('skipifconnectfailure.inc');
! 8: ?>
! 9: --FILE--
! 10: <?php
! 11: require_once("connect.inc");
! 12:
! 13: if (!is_null($tmp = @mysqli_info()))
! 14: printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
! 15:
! 16: if (!is_null($tmp = @mysqli_info(NULL)))
! 17: printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
! 18:
! 19: require "table.inc";
! 20: if (!$res = mysqli_query($link, "INSERT INTO test(id, label) VALUES (100, 'a')"))
! 21: printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
! 22:
! 23: // NOTE: empty string, no multiple insert syntax
! 24: if (!is_string($tmp = mysqli_info($link)) || ('' != $tmp))
! 25: printf("[004] Expecting string/empty, got %s/%s\n", gettype($tmp), $tmp);
! 26:
! 27: if (!$res = mysqli_query($link, "INSERT INTO test(id, label) VALUES (101, 'a'), (102, 'b')"))
! 28: printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
! 29:
! 30: if (!is_string($tmp = mysqli_info($link)) || ('' == $tmp))
! 31: printf("[006] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp);
! 32:
! 33: if ((version_compare(PHP_VERSION, '5.9.9', '>') == 1) && !is_unicode($tmp))
! 34: printf("[007] Expecting unicode, because unicode mode it on. Got binary string\n");
! 35:
! 36: if (!$res = mysqli_query($link, 'INSERT INTO test(id, label) SELECT id + 200, label FROM test'))
! 37: printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
! 38:
! 39: if (!is_string($tmp = mysqli_info($link)) || ('' == $tmp))
! 40: printf("[008] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp);
! 41:
! 42: if (!$res = mysqli_query($link, 'ALTER TABLE test MODIFY label CHAR(2)'))
! 43: printf("[009] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
! 44:
! 45: if (!is_string($tmp = mysqli_info($link)) || ('' == $tmp))
! 46: printf("[010] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp);
! 47:
! 48: if (!$res = mysqli_query($link, "UPDATE test SET label = 'b' WHERE id >= 100"))
! 49: printf("[011] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
! 50:
! 51: if (!is_string($tmp = mysqli_info($link)) || ('' == $tmp))
! 52: printf("[012] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp);
! 53:
! 54: if (!$res = mysqli_query($link, "SELECT 1"))
! 55: printf("[013] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
! 56:
! 57: if (!is_string($tmp = mysqli_info($link)) || ('' != $tmp))
! 58: printf("[014] Expecting string/empty, got %s/%s\n", gettype($tmp), $tmp);
! 59: mysqli_free_result($res);
! 60:
! 61: // NOTE: no LOAD DATA INFILE test
! 62: if ($dir = sys_get_temp_dir()) {
! 63: do {
! 64: $file = $dir . '/' . 'mysqli_info_phpt.cvs';
! 65: if (!$fp = fopen($file, 'w'))
! 66: /* ignore this error */
! 67: break;
! 68:
! 69: if (!fwrite($fp, b"100;'a';\n") ||
! 70: !fwrite($fp, b"101;'b';\n") ||
! 71: !fwrite($fp, b"102;'c';\n")) {
! 72: @unlink($file);
! 73: break;
! 74: }
! 75: fclose($fp);
! 76: if (!mysqli_query($link, "DELETE FROM test")) {
! 77: printf("[015] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
! 78: break;
! 79: }
! 80:
! 81: if (!@mysqli_query($link, sprintf("LOAD DATA LOCAL INFILE '%s' INTO TABLE test FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '\'' LINES TERMINATED BY '\n'", $file))) {
! 82: /* ok, because we might not be allowed to do this */
! 83: @unlink($file);
! 84: break;
! 85: }
! 86:
! 87: if (!is_string($tmp = mysqli_info($link)) || ('' == $tmp))
! 88: printf("[016] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp);
! 89:
! 90: unlink($file);
! 91: } while (false);
! 92: }
! 93:
! 94: print "done!";
! 95: ?>
! 96: --CLEAN--
! 97: <?php
! 98: require_once("clean_table.inc");
! 99: ?>
! 100: --EXPECTF--
! 101: done!
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>