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