xref: /PHP-5.3/ext/pdo/tests/bug_38253.phpt (revision 0f53b4e5)
1--TEST--
2PDO Common: Bug #38253 (PDO produces segfault with default fetch mode)
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$pdo = PDOTest::factory();
16
17$pdo->exec ("create table test (id integer primary key, n varchar(255))");
18$pdo->exec ("INSERT INTO test (id, n) VALUES (1, 'hi')");
19
20$pdo->setAttribute (PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_CLASS);
21$stmt = $pdo->prepare ("SELECT * FROM test");
22$stmt->execute();
23var_dump($stmt->fetchAll());
24
25$pdo = PDOTest::factory();
26
27if ($pdo->getAttribute(PDO::ATTR_DRIVER_NAME) == 'oci') {
28    $type = "clob";
29} else{
30    $type = "text";
31}
32
33$pdo->exec ("create table test2 (id integer primary key, n $type)");
34$pdo->exec ("INSERT INTO test2 (id, n) VALUES (1,'hi')");
35
36$pdo->setAttribute (PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_FUNC);
37$stmt = $pdo->prepare ("SELECT * FROM test2");
38$stmt->execute();
39var_dump($stmt->fetchAll());
40
41?>
42--EXPECTF--
43Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: No fetch class specified in %s on line %d
44
45Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error%s on line %d
46array(0) {
47}
48
49Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: No fetch function specified in %s on line %d
50
51Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error%s on line %d
52array(0) {
53}
54