Exemple #1
0
<?php

require_once "connect.inc";
$mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
$mysql->query("CREATE TABLE test_bug35517_table_1 (id INT UNSIGNED NOT NULL)");
$mysql->query("INSERT INTO test_bug35517_table_1 (id) VALUES (3000000897),(3800001532),(3900002281),(3100059612)");
$stmt = $mysql->prepare("SELECT id FROM test_bug35517_table_1");
$stmt->execute();
$stmt->bind_result($id);
while ($stmt->fetch()) {
    if (PHP_INT_SIZE == 8) {
        if (gettype($id) !== 'int' && gettype($id) != 'integer') {
            printf("[001] Expecting integer on 64bit got %s/%s\n", gettype($id), var_export($id, true));
        }
    } else {
        if (gettype($id) !== 'string') {
            printf("[002] Expecting string on 32bit got %s/%s\n", gettype($id), var_export($id, true));
        }
        if (version_compare(PHP_VERSION, '5.9.9', '>') == 1 && !is_unicode($id)) {
            printf("[003] Expecting unicode string\n");
        }
    }
    print $id;
    print "\n";
}
$stmt->close();
$mysql->query("DROP TABLE test_bug35517_table_1");
$mysql->close();
print "done!";
require_once "connect.inc";
if (!($link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))) {
<?php

require_once "connect.inc";
$mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
$mysql->query("CREATE TABLE temp (id INT UNSIGNED NOT NULL)");
$mysql->query("INSERT INTO temp (id) VALUES (3000000897),(3800001532),(3900002281),(3100059612)");
$stmt = $mysql->prepare("SELECT id FROM temp");
$stmt->execute();
$stmt->bind_result($id);
while ($stmt->fetch()) {
    if (PHP_INT_SIZE == 8) {
        if (gettype($id) !== 'int' && gettype($id) != 'integer') {
            printf("[001] Expecting integer on 64bit got %s/%s\n", gettype($id), var_export($id, true));
        }
    } else {
        if (gettype($id) !== 'string') {
            printf("[002] Expecting string on 32bit got %s/%s\n", gettype($id), var_export($id, true));
        }
        if (version_compare(PHP_VERSION, '6.0', '==') == 1 && !is_unicode($id)) {
            printf("[003] Expecting unicode string\n");
        }
    }
    print $id;
    print "\n";
}
$stmt->close();
$mysql->query("DROP TABLE temp");
$mysql->close();
print "done!";
Exemple #3
0
<?php

$drop = <<<EOSQL
DROP TABLE test_bug35103_table_1;
DROP TABLE test_bug35103_table_2;
EOSQL;
require_once "connect.inc";
$mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
$mysql->query("DROP TABLE IF EXISTS test_bug35103_table_1");
$mysql->query("CREATE TABLE test_bug35103_table_1 (a bigint(20) default NULL) ENGINE=MYISAM");
$mysql->query("INSERT INTO test_bug35103_table_1 VALUES (9223372036854775807),(-9223372036854775808),(-2147483648),(-2147483649),(-2147483647),(2147483647),(2147483648),(2147483649)");
$mysql->query("DROP TABLE IF EXISTS test_bug35103_table_2");
$mysql->query("CREATE TABLE test_bug35103_table_2 (a bigint(20) unsigned default NULL)");
$mysql->query("INSERT INTO test_bug35103_table_2 VALUES (18446744073709551615),(9223372036854775807),(9223372036854775808),(2147483647),(2147483649),(4294967295)");
$stmt = $mysql->prepare("SELECT a FROM test_bug35103_table_1 ORDER BY a");
$stmt->bind_result($v);
$stmt->execute();
$i = 0;
echo "BIG INT SIGNED, TEST\n";
while ($i++ < 8) {
    $stmt->fetch();
    echo $v, "\n";
}
$stmt->close();
echo str_repeat("-", 20), "\n";
$stmt = $mysql->prepare("SELECT a FROM test_bug35103_table_2 ORDER BY a");
$stmt->bind_result($v2);
$stmt->execute();
$j = 0;
echo "BIG INT UNSIGNED TEST\n";
while ($j++ < 6) {
<?php

$test_table_name = 'test_mysqli_prepare_no_object_table_1';
require 'table.inc';
if (false !== ($tmp = mysqli_prepare($link, false))) {
    printf("[001] Expecting boolean/false, got %s/%s\n", gettype($tmp), is_object($tmp) ? var_dump($tmp, true) : $tmp);
}
printf("a) [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (false !== ($tmp = mysqli_prepare($link, ''))) {
    printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp), is_object($tmp) ? var_dump($tmp, true) : $tmp);
}
printf("b) [%d] %s\n", mysqli_errno($link), mysqli_error($link));
mysqli_close($link);
if (!($mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket))) {
    printf("[003] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket);
}
if (false !== ($tmp = $mysqli->prepare(false))) {
    printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), is_object($tmp) ? var_dump($tmp, true) : $tmp);
}
printf("c) [%d] %s\n", $mysqli->errno, $mysqli->error);
if (false !== ($tmp = $mysqli->prepare(''))) {
    printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), is_object($tmp) ? var_dump($tmp, true) : $tmp);
}
printf("c) [%d] %s\n", $mysqli->errno, $mysqli->error);
print "done!";
error_reporting(0);
$test_table_name = 'test_mysqli_prepare_no_object_table_1';
require_once "clean_table.inc";
<?php

$drop = <<<EOSQL
DROP TABLE test_bint;
DROP TABLE test_buint;
EOSQL;
require_once "connect.inc";
$mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
$mysql->query("DROP TABLE IF EXISTS test_bint");
$mysql->query("CREATE TABLE test_bint (a bigint(20) default NULL) ENGINE=MYISAM");
$mysql->query("INSERT INTO test_bint VALUES (9223372036854775807),(-9223372036854775808),(-2147483648),(-2147483649),(-2147483647),(2147483647),(2147483648),(2147483649)");
$mysql->query("DROP TABLE IF EXISTS test_buint");
$mysql->query("CREATE TABLE test_buint (a bigint(20) unsigned default NULL)");
$mysql->query("INSERT INTO test_buint VALUES (18446744073709551615),(9223372036854775807),(9223372036854775808),(2147483647),(2147483649),(4294967295)");
$stmt = $mysql->prepare("SELECT a FROM test_bint ORDER BY a");
$stmt->bind_result($v);
$stmt->execute();
$i = 0;
echo "BIG INT SIGNED, TEST\n";
while ($i++ < 8) {
    $stmt->fetch();
    echo $v, "\n";
}
$stmt->close();
echo str_repeat("-", 20), "\n";
$stmt = $mysql->prepare("SELECT a FROM test_buint ORDER BY a");
$stmt->bind_result($v2);
$stmt->execute();
$j = 0;
echo "BIG INT UNSIGNED TEST\n";
while ($j++ < 6) {