summaryrefslogtreecommitdiff
path: root/ext/mysql/tests/mysql_query.phpt
diff options
context:
space:
mode:
Diffstat (limited to 'ext/mysql/tests/mysql_query.phpt')
-rw-r--r--ext/mysql/tests/mysql_query.phpt55
1 files changed, 31 insertions, 24 deletions
diff --git a/ext/mysql/tests/mysql_query.phpt b/ext/mysql/tests/mysql_query.phpt
index d1d4dfb8e..a5978a6c1 100644
--- a/ext/mysql/tests/mysql_query.phpt
+++ b/ext/mysql/tests/mysql_query.phpt
@@ -1,8 +1,8 @@
--TEST--
mysql_query()
--SKIPIF--
-<?php
-require_once('skipif.inc');
+<?php
+require_once('skipif.inc');
require_once('skipifconnectfailure.inc');
?>
--FILE--
@@ -26,26 +26,26 @@ if (NULL !== ($tmp = @mysql_query("SELECT 1 AS a", $link, "foo")))
if (false !== ($tmp = mysql_query('THIS IS NOT SQL', $link)))
printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
-if (false !== ($tmp = mysql_query('SELECT "this is sql but with backslash g"\g', $link)))
+if (false !== ($tmp = mysql_query("SELECT 'this is sql but with backslash g'\g", $link)))
printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
if ((0 === mysql_errno($link)) || ('' == mysql_error($link)))
printf("[006] mysql_errno()/mysql_error should return some error\n");
-if (!$res = mysql_query('SELECT "this is sql but with semicolon" AS valid ; ', $link))
+if (!$res = mysql_query("SELECT 'this is sql but with semicolon' AS valid ; ", $link))
printf("[007] [%d] %s\n", mysql_errno($link), mysql_error($link));
var_dump(mysql_fetch_assoc($res));
mysql_free_result($res);
-if (!$res = mysql_query('SELECT "a" AS ""', $link))
+if (!$res = mysql_query("SELECT 'a' AS ''", $link))
printf("[007a] [%d] %s\n", mysql_errno($link), mysql_error($link));
var_dump($tmp = mysql_fetch_assoc($res));
var_dump($tmp[""]);
mysql_free_result($res);
-if (false !== ($res = mysql_query('SELECT "this is sql but with semicolon" AS valid ; SHOW VARIABLES', $link)))
+if (false !== ($res = mysql_query("SELECT 'this is sql but with semicolon' AS valid ; SHOW VARIABLES", $link)))
printf("[008] [%d] %s\n", mysql_errno($link), mysql_error($link));
if (mysql_query('DROP PROCEDURE IF EXISTS p', $link)) {
@@ -58,7 +58,7 @@ if (mysql_query('DROP PROCEDURE IF EXISTS p', $link)) {
printf("[009] Result seems wrong, dumping\n");
var_dump($tmp);
}
- if (ini_get('unicode.semantics') && !is_unicode($tmp['p_version'])) {
+ if ((version_compare(PHP_VERSION, '5.9.9', '>') == 1) && !is_unicode($tmp['p_version'])) {
printf("[010] Expecting unicode string, dumping\n");
var_dump($tmp);
}
@@ -75,7 +75,7 @@ if (mysql_query('DROP PROCEDURE IF EXISTS p', $link)) {
printf("[012] Result seems wrong, dumping\n");
var_dump($tmp);
}
- if (ini_get('unicode.semantics') && !is_unicode($tmp['f_version'])) {
+ if ((version_compare(PHP_VERSION, '5.9.9', '>') == 1) && !is_unicode($tmp['f_version'])) {
printf("[013] Expecting unicode string, dumping\n");
var_dump($tmp);
}
@@ -92,29 +92,36 @@ if (false !== ($tmp = mysql_query("SELECT id FROM test", $link)))
print "done!";
?>
---EXPECTF--
-array(1) {
- ["valid"]=>
- string(30) "this is sql but with semicolon"
+--CLEAN--
+<?php
+require_once('connect.inc');
+
+// connect + select_db
+if (!$link = my_mysql_connect($host, $user, $passwd, $db, $port, $socket)) {
+ printf("[clean] Cannot connect to the server using host=%s/%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+ $host, $myhost, $user, $db, $port, $socket);
}
-array(1) {
- [""]=>
- string(1) "a"
+
+if (!mysql_query('DROP TABLE IF EXISTS test', $link)) {
+ printf("[clean] Failed to drop test table: [%d] %s\n", mysql_errno($link), mysql_error($link));
}
-string(1) "a"
-Warning: mysql_query(): %d is not a valid MySQL-Link resource in %s on line %d
-done!
---UEXPECTF--
+/* MySQL server may not support this - ignore errors */
+@mysql_query('DROP PROCEDURE IF EXISTS p', $link);
+@mysql_query('DROP FUNCTION IF EXISTS f', $link);
+
+mysql_close($link);
+?>
+--EXPECTF--
array(1) {
- [u"valid"]=>
- unicode(30) "this is sql but with semicolon"
+ [%u|b%"valid"]=>
+ %unicode|string%(30) "this is sql but with semicolon"
}
array(1) {
- [u""]=>
- unicode(1) "a"
+ [%u|b%""]=>
+ %unicode|string%(1) "a"
}
-unicode(1) "a"
+%unicode|string%(1) "a"
Warning: mysql_query(): %d is not a valid MySQL-Link resource in %s on line %d
done!