1--TEST-- 2PDO ODBC varying character with max/no length 3--EXTENSIONS-- 4pdo_odbc 5--SKIPIF-- 6<?php 7require 'ext/pdo/tests/pdo_test.inc'; 8PDOTest::skip(); 9?> 10--FILE-- 11<?php 12require 'ext/pdo/tests/pdo_test.inc'; 13$db = PDOTest::test_factory('ext/pdo_odbc/tests/common.phpt'); 14$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT); 15 16if (false === $db->exec('CREATE TABLE test_max_columns (id INT NOT NULL PRIMARY KEY, data varchar(max))')) { 17 if (false === $db->exec('CREATE TABLE test_max_columns (id INT NOT NULL PRIMARY KEY, data longtext)')) { 18 if (false === $db->exec('CREATE TABLE test_max_columns (id INT NOT NULL PRIMARY KEY, data CLOB)')) { 19 die("BORK: don't know how to create a long column here:\n" . implode(", ", $db->errorInfo())); 20 } 21 } 22} 23 24$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); 25 26$sizes = array(32, 64, 128, 253, 254, 255, 256, 257, 258, 512, 1024, 2048, 3998, 3999, 4000); 27 28$db->beginTransaction(); 29$insert = $db->prepare('INSERT INTO test_max_columns VALUES (?, ?)'); 30foreach ($sizes as $num) { 31 $insert->execute(array($num, str_repeat('i', $num))); 32} 33$insert = null; 34$db->commit(); 35 36foreach ($db->query('SELECT id, data from test_max_columns') as $row) { 37 $expect = str_repeat('i', $row[0]); 38 if (strcmp($expect, $row[1])) { 39 echo "Failed on size $row[id]:\n"; 40 printf("Expected %d bytes, got %d\n", strlen($expect), strlen($row['data'])); 41 echo bin2hex($expect) . "\n"; 42 echo bin2hex($row['data']) . "\n"; 43 } 44} 45 46echo "Finished\n"; 47?> 48--CLEAN-- 49<?php 50require 'ext/pdo/tests/pdo_test.inc'; 51$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt'); 52$db->exec("DROP TABLE IF EXISTS test_max_columns"); 53?> 54--EXPECT-- 55Finished 56