1--TEST-- 2PDO PgSQL Bug #38671 (PDO#getAttribute() cannot be called with platform-specific attribute names) 3--SKIPIF-- 4<?php 5if (!extension_loaded('pdo') || !extension_loaded('pdo_pgsql')) die('skip not loaded'); 6require dirname(__FILE__) . '/config.inc'; 7require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc'; 8PDOTest::skip(); 9?> 10--FILE-- 11<?php 12 13require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc'; 14$pdo = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt'); 15$pdo->setAttribute (\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); 16 17$attrs = array( 18 // Extensive test: default value and set+get values 19 PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT => array(null, true, false), 20 PDO::ATTR_EMULATE_PREPARES => array(null, true, false), 21 PDO::PGSQL_ATTR_DISABLE_PREPARES => array(null, true, false), 22 23 // Just test the default 24 PDO::ATTR_AUTOCOMMIT => array(null), 25 PDO::ATTR_PREFETCH => array(null), 26 PDO::ATTR_TIMEOUT => array(null), 27 PDO::ATTR_ERRMODE => array(null), 28 PDO::ATTR_SERVER_VERSION => array(null), 29 PDO::ATTR_CLIENT_VERSION => array(null), 30 PDO::ATTR_SERVER_INFO => array(null), 31 PDO::ATTR_CONNECTION_STATUS => array(null), 32 PDO::ATTR_CASE => array(null), 33 PDO::ATTR_CURSOR_NAME => array(null), 34 PDO::ATTR_CURSOR => array(null), 35 PDO::ATTR_ORACLE_NULLS => array(null), 36 PDO::ATTR_PERSISTENT => array(null), 37 PDO::ATTR_STATEMENT_CLASS => array(null), 38 PDO::ATTR_FETCH_TABLE_NAMES => array(null), 39 PDO::ATTR_FETCH_CATALOG_NAMES => array(null), 40 PDO::ATTR_DRIVER_NAME => array(null), 41 PDO::ATTR_STRINGIFY_FETCHES => array(null), 42 PDO::ATTR_MAX_COLUMN_LEN => array(null), 43 PDO::ATTR_DEFAULT_FETCH_MODE => array(null), 44); 45 46foreach ($attrs as $a => $vals) { 47 foreach ($vals as $v) { 48 try { 49 if (!isset($v)) { 50 var_dump($pdo->getAttribute($a)); 51 } else { 52 $pdo->setAttribute($a, $v); 53 if ($pdo->getAttribute($a) === $v) { 54 echo "OK\n"; 55 } else { 56 throw new \Exception('KO'); 57 } 58 } 59 } catch (\Exception $e) { 60 if ($e->getCode() == 'IM001') { 61 echo "ERR\n"; 62 } else { 63 echo "ERR {$e->getMessage()}\n"; 64 } 65 } 66 } 67} 68 69?> 70--EXPECTF-- 71Deprecated: PDO::getAttribute(): %s 72bool(false) 73 74Deprecated: PDO::setAttribute(): %s 75 76Deprecated: PDO::getAttribute(): %s 77OK 78 79Deprecated: PDO::setAttribute(): %s 80 81Deprecated: PDO::getAttribute(): %s 82OK 83bool(false) 84OK 85OK 86bool(false) 87OK 88OK 89ERR 90ERR 91ERR 92int(2) 93string(%d) "%s" 94string(%d) "%s" 95string(%d) "%s" 96string(31) "%s" 97int(2) 98ERR 99ERR 100int(0) 101bool(false) 102array(1) { 103 [0]=> 104 string(12) "PDOStatement" 105} 106ERR 107ERR 108string(5) "pgsql" 109ERR 110ERR 111int(4) 112 113