test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 180);
$expected = create_table($link, 'INT UNSIGNED', 0, 1000, $engine, 190);
foreach ($expected as $k => $v) {
    $expected[$k] = number_format(round($v), 0, '.', ',');
}
test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 200);
$expected = create_table($link, 'BIGINT', -1000, 1000, $engine, 210);
foreach ($expected as $k => $v) {
    $expected[$k] = number_format(round($v), 0, '.', ',');
}
test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 220);
$expected = create_table($link, 'DECIMAL(5,0)', -1000, 1000, $engine, 230);
foreach ($expected as $k => $v) {
    $expected[$k] = number_format(round($v), 0, '.', ',');
}
test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test', 'id', $expected, 240);
// http://bugs.php.net/bug.php?id=42378
if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) {
    printf("[300] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
if (mysqli_query($link, "CREATE TABLE `test` (\n  `targetport` int(11) NOT NULL default '0',\n  `sources` double(17,4) default NULL,\n  `current_sources` double(17,0) default NULL,\n  `reports` double(17,4) default NULL,\n  `current_reports` double(17,0) default NULL,\n  `targets` double(17,4) default NULL,\n  `current_targets` double(17,0) default NULL,\n  `maxsources` int(11) default NULL,\n  `maxtargets` int(11) default NULL,\n  `maxreports` int(11) default NULL,\n  `trend` float default NULL,\n  PRIMARY KEY  (`targetport`)\n) ENGINE=InnoDB DEFAULT CHARSET=latin1")) {
    do {
        $values = array();
        for ($i = 0; $i < 200; $i++) {
            $current_targets = mt_rand(-100000, 100000) / 10;
            do {
                $trend = mt_rand(0, 3) > 1 ? mt_rand(-10000, 10000) / 100 : 'NULL';
            } while (isset($values[$trend]));
            $sql = sprintf('INSERT INTO test(targetport, current_targets, maxreports, trend) VALUES (%d, %f, %s, %s)', $i, $current_targets, mt_rand(0, 1) > 0 ? mt_rand(0, 1000) : 'NULL', $trend);
            if (!mysqli_query($link, $sql)) {
                printf("[301] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
Esempio n. 2
0
    return true;
}
if (!($link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))) {
    printf("[001] Cannot connect - [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
}
/* create new table and select from it */
$expected = create_table($link, 'FLOAT', -10000, 10000, $engine, 90);
foreach ($expected as $k => $v) {
    $expected[$k] = number_format(round($v), 0, '.', ',');
}
test_format($link, 'FORMAT(col1, 0)', 'test_bug42378_table_1', NULL, array(), 100);
$expected = create_table($link, 'FLOAT', -10000, 10000, $engine, 110);
foreach ($expected as $k => $v) {
    $expected[$k] = number_format(round($v), 0, '.', ',');
}
test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test_bug42378_table_1', 'id', $expected, 120);
$expected = create_table($link, 'FLOAT UNSIGNED', 0, 10000, $engine, 130);
foreach ($expected as $k => $v) {
    $expected[$k] = number_format(round($v), 0, '.', ',');
}
test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test_bug42378_table_1', 'id', $expected, 140);
$expected = create_table($link, 'DECIMAL(5,0)', -1000, 1000, $engine, 150);
foreach ($expected as $k => $v) {
    $expected[$k] = number_format(round($v), 0, '.', ',');
}
test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test_bug42378_table_1', 'id', $expected, 160);
mysqli_close($link);
print "done!";
error_reporting(0);
$test_table_name = 'test_bug42378_table_1';
require_once "clean_table.inc";
test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test_mysqli_stmt_bind_result_format_table_1', 'id', $expected, 180);
$expected = create_table($link, 'INT UNSIGNED', 0, 1000, $engine, 190);
foreach ($expected as $k => $v) {
    $expected[$k] = number_format(round($v), 0, '.', ',');
}
test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test_mysqli_stmt_bind_result_format_table_1', 'id', $expected, 200);
$expected = create_table($link, 'BIGINT', -1000, 1000, $engine, 210);
foreach ($expected as $k => $v) {
    $expected[$k] = number_format(round($v), 0, '.', ',');
}
test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test_mysqli_stmt_bind_result_format_table_1', 'id', $expected, 220);
$expected = create_table($link, 'DECIMAL(5,0)', -1000, 1000, $engine, 230);
foreach ($expected as $k => $v) {
    $expected[$k] = number_format(round($v), 0, '.', ',');
}
test_format($link, 'id AS order_by_col, FORMAT(col1, 0)', 'test_mysqli_stmt_bind_result_format_table_1', 'id', $expected, 240);
// http://bugs.php.net/bug.php?id=42378
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_mysqli_stmt_bind_result_format_table_1")) {
    printf("[300] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
if (mysqli_query($link, "CREATE TABLE `test_mysqli_stmt_bind_result_format_table_1` (\n  `targetport` int(11) NOT NULL default '0',\n  `sources` double(17,4) default NULL,\n  `current_sources` double(17,0) default NULL,\n  `reports` double(17,4) default NULL,\n  `current_reports` double(17,0) default NULL,\n  `targets` double(17,4) default NULL,\n  `current_targets` double(17,0) default NULL,\n  `maxsources` int(11) default NULL,\n  `maxtargets` int(11) default NULL,\n  `maxreports` int(11) default NULL,\n  `trend` float default NULL,\n  PRIMARY KEY  (`targetport`)\n) ENGINE=InnoDB DEFAULT CHARSET=latin1")) {
    do {
        $values = array();
        for ($i = 0; $i < 200; $i++) {
            $current_targets = mt_rand(-100000, 100000) / 10;
            do {
                $trend = mt_rand(0, 3) > 1 ? mt_rand(-10000, 10000) / 100 : 'NULL';
            } while (isset($values[$trend]));
            $sql = sprintf('INSERT INTO test_mysqli_stmt_bind_result_format_table_1(targetport, current_targets, maxreports, trend) VALUES (%d, %f, %s, %s)', $i, $current_targets, mt_rand(0, 1) > 0 ? mt_rand(0, 1000) : 'NULL', $trend);
            if (!mysqli_query($link, $sql)) {
                printf("[301] [%d] %s\n", mysqli_errno($link), mysqli_error($link));