xref: /PHP-8.1/ext/mysqli/tests/037.phpt (revision b5a14e6c)
1--TEST--
2function test: mysqli_field_count()
3--EXTENSIONS--
4mysqli
5--SKIPIF--
6<?php
7require_once('skipifconnectfailure.inc');
8?>
9--FILE--
10<?php
11
12    require_once("connect.inc");
13
14    /*** test mysqli_connect 127.0.0.1 ***/
15    $link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
16
17    mysqli_select_db($link, $db);
18
19    mysqli_query($link, "DROP TABLE IF EXISTS test_result");
20
21    mysqli_query($link, "CREATE TABLE test_result (a int, b varchar(10)) ENGINE = " . $engine);
22
23    mysqli_query($link, "INSERT INTO test_result VALUES (1, 'foo')");
24    $ir[] = mysqli_field_count($link);
25
26    mysqli_real_query($link, "SELECT * FROM test_result");
27    $ir[] = mysqli_field_count($link);
28
29
30    var_dump($ir);
31
32    mysqli_query($link, "DROP TABLE IF EXISTS test_result");
33    mysqli_close($link);
34    print "done!";
35?>
36--CLEAN--
37<?php
38require_once("connect.inc");
39if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
40   printf("[c001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
41
42if (!mysqli_query($link, "DROP TABLE IF EXISTS test_result"))
43    printf("[c002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
44
45mysqli_close($link);
46?>
47--EXPECT--
48array(2) {
49  [0]=>
50  int(0)
51  [1]=>
52  int(2)
53}
54done!
55