Annotation of embedaddon/php/ext/mysqli/tests/mysqli_error.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: mysqli_error()
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: $tmp = NULL;
14: $link = NULL;
15:
16: if (!is_null($tmp = @mysqli_error()))
17: printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
18:
19: if (!is_null($tmp = @mysqli_error($link)))
20: printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
21:
22: if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) {
23: printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
24: $host, $user, $db, $port, $socket);
25: }
26:
27: $tmp = mysqli_error($link);
28: if (!is_string($tmp) || ('' !== $tmp))
29: printf("[004] Expecting string/empty, got %s/%s. [%d] %s\n", gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link));
30:
31: if (!mysqli_query($link, 'DROP TABLE IF EXISTS test')) {
32: printf("[005] Failed to drop old test table: [%d] %s\n", mysqli_errno($link), mysqli_error($link));
33: }
34:
35: mysqli_query($link, 'SELECT * FROM test');
36: $tmp = mysqli_error($link);
37: if (!is_string($tmp) || !preg_match("/Table '\w*\.test' doesn't exist/su", $tmp))
38: printf("[006] Expecting string/[Table... doesn't exit], got %s/%s. [%d] %s\n", gettype($tmp), $tmp, mysqli_errno($link), mysqli_error($link));
39:
40: mysqli_close($link);
41:
42: var_dump(mysqli_error($link));
43:
44: print "done!";
45: ?>
46: --EXPECTF--
47: Warning: mysqli_error(): Couldn't fetch mysqli in %s on line %d
48: NULL
49: done!
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>