xref: /PHP-7.0/ext/pdo/tests/bug_60665.phpt (revision eb33d08f)
1--TEST--
2PDO Common: Bug #60665 (call to empty() on NULL result using PDO::FETCH_LAZY returns false)
3--SKIPIF--
4<?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$db = PDOTest::factory();
16switch ($db->getAttribute(PDO::ATTR_DRIVER_NAME)) {
17	case 'oci': $from = 'from dual'; break;
18	case 'firebird': $from = 'from rdb$database'; break;
19	default: $from = ''; break;
20}
21$statement = $db->prepare("SELECT NULL AS null_value, 0 AS zero, 1 AS one $from");
22$statement->execute();
23$row = $statement->fetch(PDO::FETCH_LAZY);
24var_dump(
25    empty($row->null_value),
26    empty($row->zero),
27    !empty($row->one),
28    empty($row->missing),
29    !isset($row->null_value),
30    isset($row->zero),
31    isset($row->one),
32    !isset($row->missing)
33);
34?>
35===DONE===
36--EXPECT--
37bool(true)
38bool(true)
39bool(true)
40bool(true)
41bool(true)
42bool(true)
43bool(true)
44bool(true)
45===DONE===
46