xref: /PHP-8.1/ext/mysqli/tests/066.phpt (revision b5a14e6c)
1--TEST--
2function test: mysqli_warning object
3--EXTENSIONS--
4mysqli
5--SKIPIF--
6<?php
7require_once('skipifconnectfailure.inc');
8?>
9--FILE--
10<?php
11    require_once("connect.inc");
12
13    /*** test mysqli_connect 127.0.0.1 ***/
14    $mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
15
16    if (!mysqli_query($mysql, "SET sql_mode=''"))
17        printf("[002] Cannot set SQL-Mode, [%d] %s\n", mysqli_errno($mysql), mysqli_error($mysql));
18
19    $mysql->query("DROP TABLE IF EXISTS test_warnings");
20
21    $mysql->query("CREATE TABLE test_warnings (a int not null) ENGINE=myisam");
22
23    $mysql->query("INSERT INTO test_warnings VALUES (1),(2),(NULL)");
24
25    if (($warning = $mysql->get_warnings())) {
26        do {
27            printf("Warning\n");
28        } while ($warning->next());
29    }
30
31    $mysql->close();
32    print "done!";
33?>
34--CLEAN--
35<?php
36require_once("connect.inc");
37if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
38   printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
39
40if (!mysqli_query($link, "DROP TABLE IF EXISTS test_warnings"))
41    printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
42
43mysqli_close($link);
44?>
45--EXPECT--
46Warning
47done!
48