summaryrefslogtreecommitdiff
path: root/ext/mysqli/tests
diff options
context:
space:
mode:
authorSVN Migration <svn@php.net>2003-02-23 02:39:52 +0000
committerSVN Migration <svn@php.net>2003-02-23 02:39:52 +0000
commita9b5596a026ff2475aceb6da11c3f9fd8b24a73b (patch)
treee26eeb353f940ec2038ea7be287ea365b69255c9 /ext/mysqli/tests
parent935a58c3a219aedb5b483a880dae00ecc188a8a0 (diff)
downloadphp-git-a9b5596a026ff2475aceb6da11c3f9fd8b24a73b.tar.gz
This commit was manufactured by cvs2svn to create branch 'PHP_4_3'.
Diffstat (limited to 'ext/mysqli/tests')
-rw-r--r--ext/mysqli/tests/014.phpt66
-rw-r--r--ext/mysqli/tests/015.phpt68
-rw-r--r--ext/mysqli/tests/046.phpt31
-rw-r--r--ext/mysqli/tests/050.phpt19
-rw-r--r--ext/mysqli/tests/053.phpt18
-rw-r--r--ext/mysqli/tests/054.phpt18
-rw-r--r--ext/mysqli/tests/055.phpt17
-rw-r--r--ext/mysqli/tests/057.phpt52
8 files changed, 289 insertions, 0 deletions
diff --git a/ext/mysqli/tests/014.phpt b/ext/mysqli/tests/014.phpt
new file mode 100644
index 0000000000..8a72c42c7f
--- /dev/null
+++ b/ext/mysqli/tests/014.phpt
@@ -0,0 +1,66 @@
+--TEST--
+mysqli autocommit/commit/rollback
+--SKIPIF--
+<?php
+ include "connect.inc";
+ $link = mysqli_connect("localhost", $user, $passwd);
+ $result = mysqli_query($link, "SHOW VARIABLES LIKE 'have_innodb'");
+ $row = mysqli_fetch_row($result);
+ mysqli_free_result($result);
+ mysqli_close($link);
+
+ if ($row[1] == "DISABLED" || $row[1] == "NO") {
+ printf ("skip innodb support is not installed or enabled.");
+ }
+?>
+--FILE--
+<?php
+ include "connect.inc";
+ $link = mysqli_connect("localhost", $user, $passwd);
+
+ mysqli_select_db($link, "test");
+
+ mysqli_autocommit($link, TRUE);
+
+ mysqli_query($link,"DROP TABLE IF EXISTS ac_01");
+
+ mysqli_query($link,"CREATE TABLE ac_01(a int, b varchar(10)) type=InnoDB");
+
+ mysqli_query($link, "INSERT INTO ac_01 VALUES (1, 'foobar')");
+ mysqli_autocommit($link, FALSE);
+ mysqli_query($link, "DELETE FROM ac_01");
+ mysqli_query($link, "INSERT INTO ac_01 VALUES (2, 'egon')");
+
+ mysqli_rollback($link);
+
+ $result = mysqli_query($link, "SELECT * FROM ac_01");
+ $row = mysqli_fetch_row($result);
+ mysqli_free_result($result);
+
+ var_dump($row);
+
+ mysqli_query($link, "DELETE FROM ac_01");
+ mysqli_query($link, "INSERT INTO ac_01 VALUES (2, 'egon')");
+ mysqli_commit($link);
+
+ $result = mysqli_query($link, "SELECT * FROM ac_01");
+ $row = mysqli_fetch_row($result);
+ mysqli_free_result($result);
+
+ var_dump($row);
+
+ mysqli_close($link);
+?>
+--EXPECT--
+array(2) {
+ [0]=>
+ string(1) "1"
+ [1]=>
+ string(6) "foobar"
+}
+array(2) {
+ [0]=>
+ string(1) "2"
+ [1]=>
+ string(4) "egon"
+}
diff --git a/ext/mysqli/tests/015.phpt b/ext/mysqli/tests/015.phpt
new file mode 100644
index 0000000000..96864e8854
--- /dev/null
+++ b/ext/mysqli/tests/015.phpt
@@ -0,0 +1,68 @@
+--TEST--
+mysqli autocommit/commit/rollback with myisam
+--SKIPIF--
+<?php
+ include "connect.inc";
+ $link = mysqli_connect("localhost", $user, $passwd);
+ $result = mysqli_query($link, "SHOW VARIABLES LIKE 'have_innodb'");
+ $row = mysqli_fetch_row($result);
+ mysqli_free_result($result);
+ mysqli_close($link);
+
+ if ($row[1] == "NO") {
+ printf ("skip innodb support not installed.");
+ }
+?>
+--FILE--
+<?php
+ include "connect.inc";
+
+ $link = mysqli_connect("localhost", $user, $passwd);
+
+ mysqli_select_db($link, "test");
+
+ mysqli_autocommit($link, TRUE);
+
+ mysqli_query($link,"DROP TABLE IF EXISTS ac_01");
+
+ mysqli_query($link,"CREATE TABLE ac_01(a int, b varchar(10))");
+
+ mysqli_query($link, "INSERT INTO ac_01 VALUES (1, 'foobar')");
+ mysqli_autocommit($link, FALSE);
+
+ mysqli_query($link, "DELETE FROM ac_01");
+ mysqli_query($link, "INSERT INTO ac_01 VALUES (2, 'egon')");
+
+ mysqli_rollback($link);
+
+ $result = mysqli_query($link, "SELECT * FROM ac_01");
+ $row = mysqli_fetch_row($result);
+ mysqli_free_result($result);
+
+ var_dump($row);
+
+ mysqli_query($link, "DELETE FROM ac_01");
+ mysqli_query($link, "INSERT INTO ac_01 VALUES (2, 'egon')");
+ mysqli_commit($link);
+
+ $result = mysqli_query($link, "SELECT * FROM ac_01");
+ $row = mysqli_fetch_row($result);
+ mysqli_free_result($result);
+
+ var_dump($row);
+
+ mysqli_close($link);
+?>
+--EXPECT--
+array(2) {
+ [0]=>
+ string(1) "2"
+ [1]=>
+ string(4) "egon"
+}
+array(2) {
+ [0]=>
+ string(1) "2"
+ [1]=>
+ string(4) "egon"
+}
diff --git a/ext/mysqli/tests/046.phpt b/ext/mysqli/tests/046.phpt
new file mode 100644
index 0000000000..d4a93ca277
--- /dev/null
+++ b/ext/mysqli/tests/046.phpt
@@ -0,0 +1,31 @@
+--TEST--
+mysqli_stmt_affected_rows (delete)
+--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_affected");
+ mysqli_query($link, "CREATE TABLE test_affected (foo int)");
+
+ mysqli_query($link, "INSERT INTO test_affected VALUES (1),(2),(3),(4),(5)");
+
+ $stmt = mysqli_prepare($link, "DELETE FROM test_affected WHERE foo=?");
+ mysqli_bind_param($stmt, &$c1, MYSQLI_BIND_INT);
+
+ $c1 = 2;
+
+ mysqli_execute($stmt);
+ $x = mysqli_stmt_affected_rows($stmt);
+
+ mysqli_stmt_close($stmt);
+ var_dump($x==1);
+
+ mysqli_close($link);
+?>
+--EXPECT--
+bool(true)
diff --git a/ext/mysqli/tests/050.phpt b/ext/mysqli/tests/050.phpt
new file mode 100644
index 0000000000..9ab5d346f8
--- /dev/null
+++ b/ext/mysqli/tests/050.phpt
@@ -0,0 +1,19 @@
+--TEST--
+non freed statement test
+--FILE--
+<?php
+ include "connect.inc";
+
+ /************************
+ * non freed stamement
+ ************************/
+ $link = mysqli_connect("localhost", $user, $passwd);
+
+ $stmt = mysqli_prepare($link, "SELECT CURRENT_USER()");
+ mysqli_execute($stmt);
+
+ mysqli_close($link);
+ printf("Ok\n");
+?>
+--EXPECT--
+Ok
diff --git a/ext/mysqli/tests/053.phpt b/ext/mysqli/tests/053.phpt
new file mode 100644
index 0000000000..f542d0f099
--- /dev/null
+++ b/ext/mysqli/tests/053.phpt
@@ -0,0 +1,18 @@
+--TEST--
+not freed resultset
+--FILE--
+<?php
+ include "connect.inc";
+
+ /************************
+ * non freed resultset
+ ************************/
+ $link = mysqli_connect("localhost", $user, $passwd);
+
+ $result = mysqli_query($link, "SELECT CURRENT_USER()");
+ mysqli_close($link);
+ printf("Ok\n");
+
+?>
+--EXPECT--
+Ok
diff --git a/ext/mysqli/tests/054.phpt b/ext/mysqli/tests/054.phpt
new file mode 100644
index 0000000000..eab207db4d
--- /dev/null
+++ b/ext/mysqli/tests/054.phpt
@@ -0,0 +1,18 @@
+--TEST--
+free resultset after close
+--FILE--
+<?php
+ include "connect.inc";
+
+ /************************
+ * free resultset after close
+ ************************/
+ $link = mysqli_connect("localhost", $user, $passwd);
+
+ $result1 = mysqli_query($link, "SELECT CURRENT_USER()");
+ mysqli_close($link);
+ mysqli_free_result($result1);
+ printf("Ok\n");
+?>
+--EXPECT--
+Ok
diff --git a/ext/mysqli/tests/055.phpt b/ext/mysqli/tests/055.phpt
new file mode 100644
index 0000000000..e777bcfc99
--- /dev/null
+++ b/ext/mysqli/tests/055.phpt
@@ -0,0 +1,17 @@
+--TEST--
+free nothing
+--FILE--
+<?php
+ include "connect.inc";
+
+ /************************
+ * don't free anything
+ ************************/
+ $link = mysqli_connect("localhost", $user, $passwd);
+
+ $result2 = mysqli_query($link, "SELECT CURRENT_USER()");
+ $stmt2 = mysqli_prepare($link, "SELECT CURRENT_USER()");
+ printf("Ok\n");
+?>
+--EXPECT--
+Ok
diff --git a/ext/mysqli/tests/057.phpt b/ext/mysqli/tests/057.phpt
new file mode 100644
index 0000000000..a7333a0d93
--- /dev/null
+++ b/ext/mysqli/tests/057.phpt
@@ -0,0 +1,52 @@
+--TEST--
+mysqli_prepare_result
+--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_store_result");
+ mysqli_query($link,"CREATE TABLE test_store_result (a int)");
+
+ mysqli_query($link, "INSERT INTO test_store_result VALUES (1),(2),(3)");
+
+ $stmt = mysqli_prepare($link, "SELECT * FROM test_store_result");
+ mysqli_execute($stmt);
+
+ /* this should produce an out of sync error */
+ if ($result = mysqli_query($link, "SELECT * FROM test_store_result")) {
+ mysqli_free_result($result);
+ printf ("Query ok\n");
+ }
+ mysqli_stmt_close($stmt);
+
+ $stmt = mysqli_prepare($link, "SELECT * FROM test_store_result");
+ mysqli_execute($stmt);
+ $result1 = mysqli_prepare_result($stmt);
+ mysqli_stmt_store_result($stmt);
+
+ printf ("Rows: %d\n", mysqli_stmt_affected_rows($stmt));
+
+ /* this should show an error, cause results are not buffered */
+ if ($result = mysqli_query($link, "SELECT * FROM test_store_result")) {
+ $row = mysqli_fetch_row($result);
+ mysqli_free_result($result);
+ }
+
+
+ var_dump($row);
+
+ mysqli_free_result($result1);
+ mysqli_stmt_close($stmt);
+ mysqli_close($link);
+?>
+--EXPECT--
+Rows: 3
+array(1) {
+ [0]=>
+ string(1) "1"
+}