1--TEST-- 2PDOStatement::fetchColumn() invalid column index 3--SKIPIF-- 4<?php # vim:ft=php 5if (!extension_loaded('pdo')) die('skip'); 6$dir = getenv('REDIR_TEST_DIR'); 7if (false == $dir) die('skip no driver'); 8require_once $dir . 'pdo_test.inc'; 9PDOTest::skip(); 10?> 11--FILE-- 12<?php 13if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.dirname(__FILE__) . '/../../pdo/tests/'); 14require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc'; 15 16function fetchColumn($stmt, $index) { 17 $stmt->execute(); 18 return $stmt->fetchColumn($index); 19} 20 21$conn = PDOTest::factory(); 22$query = 'SELECT 1'; 23 24switch ($conn->getAttribute(PDO::ATTR_DRIVER_NAME)) { 25 case 'oci': 26 $query .= ' FROM DUAL'; 27 break; 28 case 'firebird': 29 $query .= ' FROM RDB$DATABASE'; 30 break; 31} 32 33$stmt = $conn->prepare($query); 34 35var_dump(fetchColumn($stmt, -1)); 36var_dump(fetchColumn($stmt, 0)); 37var_dump(fetchColumn($stmt, 1)); 38?> 39--EXPECTF-- 40Warning: PDOStatement::fetchColumn(): SQLSTATE[HY000]: General error: Invalid column index in %s 41bool(false) 42string(1) "1" 43 44Warning: PDOStatement::fetchColumn(): SQLSTATE[HY000]: General error: Invalid column index in %s 45bool(false) 46