Author: uwendel
Date: 2007-07-17 20:19:42 +0200 (Tue, 17 Jul 2007)
New Revision: 777
Added:
trunk/tests/ext/mysqli/mysqli_fetch_assoc_bit.phpt
Log:
Adding test stub to fetch BIT columns. I've no cluie how a PHP user is supposed to work
with this.
Added: trunk/tests/ext/mysqli/mysqli_fetch_assoc_bit.phpt
===================================================================
--- trunk/tests/ext/mysqli/mysqli_fetch_assoc_bit.phpt 2007-07-17 16:20:40 UTC (rev 776)
+++ trunk/tests/ext/mysqli/mysqli_fetch_assoc_bit.phpt 2007-07-17 18:19:42 UTC (rev 777)
@@ -0,0 +1,61 @@
+--TEST--
+mysqli_fetch_assoc() - BIT
+--SKIPIF--
+<?php
+ require_once('skipif.inc');
+ require_once('skipifemb.inc');
+ require_once('connect.inc');
+ require_once('table.inc');
+ if (mysqli_get_server_version($link) < 50003)
+ // b'001' syntax not supported before 5.0.3
+ die("skip Syntax used for test not supported with MySQL Server before 5.0.3");
+ if (!$IS_MYSQLND && (mysqli_get_client_version() < 50003))
+ // better don't trust libmysql before 5.0.3
+ die("skip Syntax used for test not supported with MySQL Server before 5.0.3");
+?>
+--FILE--
+<?php
+ require('connect.inc');
+
+ if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
+ printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***,
dbname=%s, port=%s, socket=%s\n",
+ $host, $user, $db, $port, $socket);
+
+ for ($bits = 4; $bits < 64; $bits++) {
+ $max_value = pow(2, $bits) - 1;
+ $tests = 0;
+ if (!mysqli_query($link, "DROP TABLE IF EXISTS test") ||
+ !mysqli_query($link, $sql = sprintf('CREATE TABLE test(id INT, label BIT(%d))
ENGINE="%s"', $bits, $engine)))
+ printf("[002 - %d] [%d] %s\n",$bits, mysqli_errno($link), mysqli_error($link));
+
+ while ($tests < min($max_value, 20)) {
+ $tests++;
+ $value = mt_rand(0, $max_value);
+ $sql = sprintf("INSERT INTO test(id, label) VALUES (%d, b'%s')", $value,
decbin($value));
+ if (!mysqli_query($link, $sql))
+ printf("[003 - %d] [%d] %s\n", $bits, mysqli_errno($link), mysqli_error($link));
+
+ $sql = sprintf("SELECT id, label + 0 AS _label0, label FROM test WHERE id = %d",
$value);
+ if (!$res = mysqli_query($link, $sql))
+ printf("[004 - %d] [%d] %s\n", $bits, mysqli_errno($link), mysqli_error($link));
+
+ if (!$row = mysqli_fetch_assoc($res))
+ printf("[005 - %d] [%d] %s\n", $bits, mysqli_errno($link), mysqli_error($link));
+
+ if ((float)$row['id'] != (float)$row['_label0']) {
+ printf("[006 - %d] Looks like the INSERT and/or SELECT has failed, expecting %s ?=
%s\n",
+ $bits, $row['id'], $row['_label0']);
+ }
+
+ debug_zval_dump($row);
+ die("no int?\n");
+
+ }
+
+ }
+
+ mysqli_close($link);
+ print "done!";
+?>
+--EXPECTF--
+done!
\ No newline at end of file
| Thread |
|---|
| • PHP mysqlnd svn commit: r777 - trunk/tests/ext/mysqli | uwendel | 17 Jul |