summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/mysqli/tests/036.phpt43
-rw-r--r--ext/mysqli/tests/037.phpt34
-rw-r--r--ext/mysqli/tests/038.phpt31
-rw-r--r--ext/mysqli/tests/039.phpt24
-rw-r--r--ext/mysqli/tests/040.phpt31
-rw-r--r--ext/mysqli/tests/041.phpt24
6 files changed, 187 insertions, 0 deletions
diff --git a/ext/mysqli/tests/036.phpt b/ext/mysqli/tests/036.phpt
new file mode 100644
index 0000000000..080c6e32e4
--- /dev/null
+++ b/ext/mysqli/tests/036.phpt
@@ -0,0 +1,43 @@
+--TEST--
+function test: mysqli_insert_id()
+--FILE--
+<?php
+
+ include "connect.inc";
+
+ /*** test mysqli_connect 127.0.0.1 ***/
+ $link = mysqli_connect("localhost", $user, $passwd);
+
+ mysqli_select_db($link, "test");
+
+ mysqli_query($link, "DROP TABLE IF EXISTS t036");
+
+ mysqli_query($link, "CREATE TABLE t036 (a bigint not null auto_increment primary key, b varchar(10))");
+
+
+ mysqli_query($link, "INSERT INTO t036 (b) VALUES ('foo1')");
+ $test[] = mysqli_insert_id($link);
+
+ /* we have to insert more values, cause lexer sets auto_increment to max_int
+ see mysql bug #54. So we don't check for the value, only for type (which must
+ be type string)
+ */
+
+ mysqli_query($link, "ALTER TABLE t036 AUTO_INCREMENT=9999999999999998");
+ mysqli_query($link, "INSERT INTO t036 (b) VALUES ('foo2')");
+ mysqli_query($link, "INSERT INTO t036 (b) VALUES ('foo3')");
+ mysqli_query($link, "INSERT INTO t036 (b) VALUES ('foo4')");
+ $x = mysqli_insert_id($link);
+ $test[] = is_string($x);
+
+ var_dump($test);
+
+ mysqli_close($link);
+?>
+--EXPECT--
+array(2) {
+ [0]=>
+ int(1)
+ [1]=>
+ bool(true)
+}
diff --git a/ext/mysqli/tests/037.phpt b/ext/mysqli/tests/037.phpt
new file mode 100644
index 0000000000..f8b8a13f1a
--- /dev/null
+++ b/ext/mysqli/tests/037.phpt
@@ -0,0 +1,34 @@
+--TEST--
+function test: mysqli_field_count()
+--FILE--
+<?php
+
+ include "connect.inc";
+
+ /*** test mysqli_connect 127.0.0.1 ***/
+ $link = mysqli_connect("localhost", $user, $passwd);
+
+ mysqli_select_db($link, "test");
+
+ mysqli_query($link, "DROP TABLE IF EXISTS test_result");
+
+ mysqli_query($link, "CREATE TABLE test_result (a int, b varchar(10))");
+
+ mysqli_query($link, "INSERT INTO test_result VALUES (1, 'foo')");
+ $ir[] = mysqli_field_count($link);
+
+ mysqli_real_query($link, "SELECT * FROM test_result");
+ $ir[] = mysqli_field_count($link);
+
+
+ var_dump($ir);
+
+ mysqli_close($link);
+?>
+--EXPECT--
+array(2) {
+ [0]=>
+ int(0)
+ [1]=>
+ int(2)
+}
diff --git a/ext/mysqli/tests/038.phpt b/ext/mysqli/tests/038.phpt
new file mode 100644
index 0000000000..858b3e3393
--- /dev/null
+++ b/ext/mysqli/tests/038.phpt
@@ -0,0 +1,31 @@
+--TEST--
+function test: mysqli_num_fields()
+--FILE--
+<?php
+
+ include "connect.inc";
+
+ /*** test mysqli_connect 127.0.0.1 ***/
+ $link = mysqli_connect("localhost", $user, $passwd);
+
+ mysqli_select_db($link, "test");
+
+ mysqli_query($link, "DROP TABLE IF EXISTS test_result");
+
+ mysqli_query($link, "CREATE TABLE test_result (a int, b varchar(10))");
+
+ mysqli_query($link, "INSERT INTO test_result VALUES (1, 'foo')");
+
+ mysqli_real_query($link, "SELECT * FROM test_result");
+ if (mysqli_field_count($link)) {
+ $result = mysqli_store_result($link);
+ $num = mysqli_num_fields($result);
+ mysqli_free_result($result);
+ }
+
+ var_dump($num);
+
+ mysqli_close($link);
+?>
+--EXPECT--
+int(2)
diff --git a/ext/mysqli/tests/039.phpt b/ext/mysqli/tests/039.phpt
new file mode 100644
index 0000000000..6ddb37bc5f
--- /dev/null
+++ b/ext/mysqli/tests/039.phpt
@@ -0,0 +1,24 @@
+--TEST--
+function test: mysqli_num_fields() 2
+--FILE--
+<?php
+
+ include "connect.inc";
+
+ /*** test mysqli_connect 127.0.0.1 ***/
+ $link = mysqli_connect("localhost", $user, $passwd);
+
+ mysqli_real_query($link, "SHOW VARIABLES");
+
+ if (mysqli_field_count($link)) {
+ $result = mysqli_store_result($link);
+ $num = mysqli_num_fields($result);
+ mysqli_free_result($result);
+ }
+
+ var_dump($num);
+
+ mysqli_close($link);
+?>
+--EXPECT--
+int(2)
diff --git a/ext/mysqli/tests/040.phpt b/ext/mysqli/tests/040.phpt
new file mode 100644
index 0000000000..477e2a5274
--- /dev/null
+++ b/ext/mysqli/tests/040.phpt
@@ -0,0 +1,31 @@
+--TEST--
+function test: mysqli_num_rows()
+--FILE--
+<?php
+
+ include "connect.inc";
+
+ /*** test mysqli_connect 127.0.0.1 ***/
+ $link = mysqli_connect("localhost", $user, $passwd);
+
+ mysqli_select_db($link, "test");
+
+ mysqli_query($link, "DROP TABLE IF EXISTS test_result");
+
+ mysqli_query($link, "CREATE TABLE test_result (a int, b varchar(10))");
+
+ mysqli_query($link, "INSERT INTO test_result VALUES (1, 'foo')");
+
+ mysqli_real_query($link, "SELECT * FROM test_result");
+ if (mysqli_field_count($link)) {
+ $result = mysqli_store_result($link);
+ $num = mysqli_num_rows($result);
+ mysqli_free_result($result);
+ }
+
+ var_dump($num);
+
+ mysqli_close($link);
+?>
+--EXPECT--
+int(1)
diff --git a/ext/mysqli/tests/041.phpt b/ext/mysqli/tests/041.phpt
new file mode 100644
index 0000000000..6fb8ee7e3f
--- /dev/null
+++ b/ext/mysqli/tests/041.phpt
@@ -0,0 +1,24 @@
+--TEST--
+function test: mysqli_warning_count()
+--FILE--
+<?php
+
+ include "connect.inc";
+
+ /*** test mysqli_connect 127.0.0.1 ***/
+ $link = mysqli_connect("localhost", $user, $passwd);
+
+ mysqli_select_db($link, "test");
+
+ mysqli_query($link, "DROP TABLE IF EXISTS test_warnings");
+
+ mysqli_query($link, "CREATE TABLE test_warnings (a int not null");
+
+ mysqli_query($link, "INSERT INTO test_warnings VALUES (1),(2),(NULL)");
+ $num = mysqli_warning_count($link);
+ var_dump($num);
+
+ mysqli_close($link);
+?>
+--EXPECT--
+int(1)