summaryrefslogtreecommitdiff
path: root/ext/mysqli/tests/mysqli_options_int_and_float_native.phpt
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@baserock.org>2013-03-14 05:42:27 +0000
committer <>2013-04-03 16:25:08 +0000
commitc4dd7a1a684490673e25aaf4fabec5df138854c4 (patch)
tree4d57c44caae4480efff02b90b9be86f44bf25409 /ext/mysqli/tests/mysqli_options_int_and_float_native.phpt
downloadphp2-master.tar.gz
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/mysqli/tests/mysqli_options_int_and_float_native.phpt')
-rw-r--r--ext/mysqli/tests/mysqli_options_int_and_float_native.phpt109
1 files changed, 109 insertions, 0 deletions
diff --git a/ext/mysqli/tests/mysqli_options_int_and_float_native.phpt b/ext/mysqli/tests/mysqli_options_int_and_float_native.phpt
new file mode 100644
index 0000000..4b0c947
--- /dev/null
+++ b/ext/mysqli/tests/mysqli_options_int_and_float_native.phpt
@@ -0,0 +1,109 @@
+--TEST--
+mysqli_options() - MYSQLI_OPT_INT_AND_FLOAT_NATIVE
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifemb.inc');
+require_once('skipifconnectfailure.inc');
+
+require_once('connect.inc');
+if (!$IS_MYSQLND)
+ die("skip mysqlnd only test");
+?>
+--FILE--
+<?php
+ require_once("connect.inc");
+
+
+ $types = array(
+ 'BIT' => array('BIT(8)', 0),
+ 'TINYINT' => array('TINYINT', 120),
+ 'BOOL' => array('BOOL', 0),
+ 'BOOLEAN' => array('BOOLEAN', 1),
+ 'SMALLINT' => array('SMALLINT', 32000),
+ 'MEDIUMINT' => array('MEDIUMINT', 999),
+ 'INT' => array('INT', 999),
+ 'BIGINT' => array('BIGINT', 999),
+ 'FLOAT' => array('FLOAT', 1.3),
+ 'DOUBLE' => array('DOUBLE', -1.3),
+ );
+
+ foreach ($types as $name => $data) {
+ $link = mysqli_init();
+ if (!mysqli_options($link, MYSQLI_OPT_INT_AND_FLOAT_NATIVE, 1)) {
+ printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ continue;
+ }
+
+ if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) {
+ printf("[002] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+ continue;
+ }
+
+
+ if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) {
+ printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ continue;
+ }
+
+ if (!mysqli_query($link, sprintf("CREATE TABLE test (id %s)", $data[0]))) {
+ printf("[004] TODO [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ continue;
+ }
+
+ if (!mysqli_query($link, sprintf("INSERT INTO test(id) VALUES (%f)", $data[1]))) {
+ printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ continue;
+ }
+
+ if (!$res = mysqli_query($link, "SELECT id FROM test")) {
+ printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ continue;
+ }
+
+ $row = mysqli_fetch_assoc($res);
+ mysqli_free_result($res);
+
+ if ($row['id'] !== $data[1]) {
+ printf("[007] Expecting %s - %s/%s got %s/%s\n",
+ $name,
+ $data[1], gettype($data[1]), $row['id'], gettype($row['id']));
+ }
+ mysqli_close($link);
+
+ $link = mysqli_init();
+ if (!mysqli_options($link, MYSQLI_OPT_INT_AND_FLOAT_NATIVE, 0)) {
+ printf("[008] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ continue;
+ }
+
+ if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket)) {
+ printf("[009] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
+ continue;
+ }
+
+ if (!$res = mysqli_query($link, "SELECT id FROM test")) {
+ printf("[010] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
+ continue;
+ }
+
+ $row = mysqli_fetch_assoc($res);
+ mysqli_free_result($res);
+
+ if (!is_string($row['id']) || ($row['id'] != $data[1])) {
+ printf("[011] Expecting %s - %s/string got %s/%s\n",
+ $name,
+ $data[1], $row['id'], gettype($row['id']));
+ }
+ mysqli_close($link);
+
+ }
+
+ print "done!";
+?>
+--CLEAN--
+<?php
+ require_once("clean_table.inc");
+?>
+--EXPECTF--
+done! \ No newline at end of file