]> granicus.if.org Git - php/commitdiff
Portability improvements
authorUlf Wendel <uw@php.net>
Tue, 8 Jun 2010 14:29:05 +0000 (14:29 +0000)
committerUlf Wendel <uw@php.net>
Tue, 8 Jun 2010 14:29:05 +0000 (14:29 +0000)
ext/mysqli/tests/bug34810.phpt
ext/mysqli/tests/bug50772.phpt

index 998d9f015b3e88f5d74f7db7a99beea235d01781..35eb71753461fc7a59adfd9b276c5c3391a6894a 100644 (file)
@@ -24,7 +24,24 @@ class DbConnection {
                $mysql->query("CREATE TABLE test_warnings (a int not null)");
                $mysql->query("SET sql_mode=''");
                $mysql->query("INSERT INTO test_warnings VALUES (1),(2),(NULL)");
-               var_dump($mysql->get_warnings());
+
+               $warning = $mysql->get_warnings();
+               if (!$warning)
+                       printf("[001] No warning!\n");
+
+               if ($warning->errno == 1048 || $warning->errno == 1253) {
+                       /* 1048 - Column 'a' cannot be null, 1263 - Data truncated; NULL supplied to NOT NULL column 'a' at row */
+                       if ("HY000" != $warning->sqlstate)
+                               printf("[003] Wrong sql state code: %s\n", $warning->sqlstate);
+
+                       if ("" == $warning->message)
+                               printf("[004] Message string must not be empty\n");
+
+
+               } else {
+                       printf("[002] Empty error message!\n");
+                       var_dump($warning);
+               }
        }
 }
 
@@ -117,12 +134,4 @@ object(mysqli)#%d (%d) {
   [%u|b%"warning_count"]=>
   NULL
 }
-object(mysqli_warning)#%d (%d) {
-  [%u|b%"message"]=>
-  %unicode|string%(25) "Column 'a' cannot be null"
-  [%u|b%"sqlstate"]=>
-  %unicode|string%(5) "HY000"
-  [%u|b%"errno"]=>
-  int(1048)
-}
 Done
index 4724d0f29e4f77877dc7d3f6861494a97ba159bd..eecef84ad2e23f246b7da11fc65bfafbbbca77f2 100644 (file)
@@ -12,7 +12,7 @@ require_once('skipifconnectfailure.inc');
 
        // These calls fail
        $db1->options(MYSQLI_OPT_CONNECT_TIMEOUT, 3);
-       $db1->real_connect($host, $user, $passwd);
+       my_mysqli_real_connect($db1, $host, $user, $passwd, $db, $port, $socket);
        if(mysqli_connect_error()) {
                echo "error 1\n";
        } else {
@@ -22,7 +22,7 @@ require_once('skipifconnectfailure.inc');
        $db2 = mysqli_init();
 
        $db2->options(MYSQLI_OPT_CONNECT_TIMEOUT, 3);
-       $db2->real_connect($host, $user, $passwd);
+       my_mysqli_real_connect($db2, $host, $user, $passwd, $db, $port, $socket);
        if(mysqli_connect_error()) {
                echo "error 2\n";
        } else {