Ejemplo n.º 1
0
test_type($db, 360, 'DATETIME', '2008-03-23 14:38:00');
test_type($db, 370, 'YEAR', 2008, $is_mysqlnd ? 2008 : '2008');
test_type($db, 380, 'CHAR(1)', 'a');
test_type($db, 390, 'CHAR(10)', '0123456789');
test_type($db, 400, 'CHAR(255)', str_repeat('z', 255));
test_type($db, 410, 'VARCHAR(1)', 'a');
test_type($db, 420, 'VARCHAR(10)', '0123456789');
test_type($db, 430, 'VARCHAR(255)', str_repeat('z', 255));
test_type($db, 440, 'BINARY(1)', str_repeat('a', 1));
test_type($db, 450, 'BINARY(255)', str_repeat('b', 255));
test_type($db, 460, 'VARBINARY(1)', str_repeat('a', 1));
test_type($db, 470, 'VARBINARY(255)', str_repeat('b', 255));
test_type($db, 480, 'TINYBLOB', str_repeat('b', 255));
test_type($db, 490, 'BLOB', str_repeat('b', 256));
test_type($db, 500, 'MEDIUMBLOB', str_repeat('b', 256));
test_type($db, 510, 'LONGBLOB', str_repeat('b', 256));
test_type($db, 520, 'TINYTEXT', str_repeat('b', 255));
test_type($db, 530, 'TINYTEXT BINARY', str_repeat('b', 255));
test_type($db, 560, 'TEXT', str_repeat('b', 256));
test_type($db, 570, 'TEXT BINARY', str_repeat('b', 256));
test_type($db, 580, 'MEDIUMTEXT', str_repeat('b', 256));
test_type($db, 590, 'MEDIUMTEXT BINARY', str_repeat('b', 256));
test_type($db, 600, 'LONGTEXT', str_repeat('b', 256));
test_type($db, 610, 'LONGTEXT BINARY', str_repeat('b', 256));
test_type($db, 620, "ENUM('yes', 'no') DEFAULT 'yes'", 'no');
test_type($db, 630, "SET('yes', 'no') DEFAULT 'yes'", 'no');
test_type($db, 640, 'DECIMAL(3,2)', -1.01, '-1.01');
echo "done!\n";
require dirname(__FILE__) . '/mysql_pdo_test.inc';
$db = MySQLPDOTest::factory();
$db->exec('DROP TABLE IF EXISTS test');
Ejemplo n.º 2
0
function test_type(&$db, $offset, $sql_type, $value, $ret_value = NULL, $pattern = NULL)
{
    $db->exec('DROP TABLE IF EXISTS test');
    $sql = sprintf('CREATE TABLE test(id INT, label %s) ENGINE=%s', $sql_type, MySQLPDOTest::getTableEngine());
    @$db->exec($sql);
    if ($db->errorCode() != 0) {
        // not all MySQL Server versions and/or engines might support the type
        return true;
    }
    $stmt = $db->prepare('INSERT INTO test(id, label) VALUES (?, ?)');
    $stmt->bindValue(1, $offset);
    $stmt->bindValue(2, $value);
    if (!$stmt->execute()) {
        printf("[%03d + 1] INSERT failed, %s\n", $offset, var_export($stmt->errorInfo(), true));
        return false;
    }
    $stmt = $db->query('SELECT  id, label FROM test');
    $row = $stmt->fetch(PDO::FETCH_ASSOC);
    var_dump($row);
    var_dump($value);
    return true;
}
$db = MySQLPDOTest::factory();
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
test_type($db, 20, 'BIT(8)', 1);
echo "done!\n";
require dirname(__FILE__) . '/mysql_pdo_test.inc';
$db = MySQLPDOTest::factory();
$db->exec('DROP TABLE IF EXISTS test');
    $stmt->closeCursor();
    if ($row['label'] != $row_string['label']) {
        printf("%s - STRINGIGY = %s, NATIVE = %s\n", $sql_type, var_export($row_string['label'], true), var_export($row['label'], true));
        return false;
    }
    return true;
}
$db = MySQLPDOTest::factory();
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false);
$stmt = $db->prepare('SELECT @@sql_mode AS _mode');
$stmt->execute();
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$real_as_float = false === stristr($row['_mode'], "REAL_AS_FLOAT") ? false : true;
test_type($db, 100, 'REAL ZEROFILL', -1.01, NULL, '/^[0]*0$/');
test_type($db, 110, 'REAL ZEROFILL', 1.01, NULL, $real_as_float ? '/^[0]*1\\.0.*$/' : '/^[0]*1\\.01$/');
test_type($db, 120, 'REAL UNSIGNED ZEROFILL', 1.01, NULL, $real_as_float ? '/^[0]*1\\..*$/' : '/^[0]*1\\.01$/');
test_type($db, 130, 'DOUBLE ZEROFILL', -1.01, NULL, '/^[0]*0$/');
test_type($db, 140, 'DOUBLE ZEROFILL', 1.01, NULL, '/^[0]*1\\.01$/');
test_type($db, 150, 'DOUBLE UNSIGNED ZEROFILL', 1.01, NULL, '/^[0]*1\\.01$/');
test_type($db, 160, 'FLOAT ZEROFILL', -1.01, NULL, '/^[0]*0$/');
test_type($db, 170, 'FLOAT ZEROFILL', 1, NULL, '/^[0]*1$/');
test_type($db, 180, 'FLOAT UNSIGNED ZEROFILL', -1, NULL, '/^[0]*0$/');
test_type($db, 190, 'DECIMAL ZEROFILL', -1.01, NULL, '/^[0]*0$/');
test_type($db, 200, 'DECIMAL ZEROFILL', 1.01, NULL, '/^[0]*1$/');
test_type($db, 210, 'DECIMAL UNSIGNED ZEROFILL', 1.01, NULL, '/^[0]*1$/');
test_type($db, 220, 'NUMERIC ZEROFILL', -1, NULL, '/^[0]*0$/');
test_type($db, 230, 'NUMERIC ZEROFILL', 1, NULL, '/^[0]*1$/');
test_type($db, 240, 'NUMERIC UNSIGNED ZEROFILL', 1.01, NULL, '/^[0]*1$/');
echo "done!\n";
Ejemplo n.º 4
0
		$type[$key] = array(
			'yprice' => (int) $item['yprice'],
			'nprice' => (int) $item['nprice']
		);

		return $type;
	}



	$new_items = array();
	foreach ($items as $key => $item) {
		
		$item_code = $item['code'];
		$test_item = test_type($item);

		// 
		if( isset($test_item['intime']) ){
			$key = 'intime';
		}elseif( isset($test_item['outtime']) ){
			$key = 'outtime';
		}
		$new_items[$item_code][$key]['yprice'] += $test_item[$key]['yprice'];
		$new_items[$item_code][$key]['nprice'] += $test_item[$key]['nprice'];

	}

	?>
	<div class="col">
		<div class="cell">