+ fail("COMMIT");
+ break;
+ }
+ succ("COMMIT");
+
+ $arr_ip = array("1.1.1.1", "127.0.0.1", "255.255.255.255", "255.255.0.0" );
+
+ if ($bdb->query("DROP TABLE IF EXISTS test_ip;") == FALSE) {
+ fail("DROP TABLE test_ip");
+ break;
+ }
+ succ("DROP TABLE test_ip");
+
+ if ($bdb->query("CREATE TABLE test_ip (
+ code integer, -- insertion code
+ ip integer, -- ip v4 address
+ atime timestamp DEFAULT to_timestamp(0) -- access time
+ ); ") == FALSE) {
+ fail("CREATE TABLE test_ip");
+ break;
+ }
+ succ("CREATE TABLE test_ip");
+
+ foreach ($arr_ip as $i) {
+ $v = $v_or = ip2long($i);
+ if (PHP_INT_SIZE == 8 && $v & 0x80000000)
+ $v = 0xffffffff00000000 | $v_or;
+
+ if ($bdb->query(sprintf("INSERT INTO test_ip (ip, atime) VALUES (CAST(%d AS integer), '1999-01-08 04:05:06');", $v)) == FALSE) {
+ printf("%s<br>\n", $bdb->last_error());
+ fail("INSERT INTO test_ip ".$i." V: ".$v." V_or: ".$v_or);
+ break;
+ }
+ succ("INSERT INTO test_ip ".$i." V: ".$v." V_or: ".$v_or);
+ }
+
+ if (($ip_pg = $bdb->query(sprintf("SELECT * FROM test_ip ORDER BY code;"))) == FALSE) {
+ printf("%s<br>\n", $bdb->last_error());
+ fail("SELECT * FROM test_ip");