xref: /PHP-8.3/ext/pdo/tests/bug_60665.phpt (revision 74859783)
1--TEST--
2PDO Common: Bug #60665 (call to empty() on NULL result using PDO::FETCH_LAZY returns false)
3--EXTENSIONS--
4pdo
5--SKIPIF--
6<?php
7$dir = getenv('REDIR_TEST_DIR');
8if (false == $dir) die('skip no driver');
9require_once $dir . 'pdo_test.inc';
10PDOTest::skip();
11?>
12--FILE--
13<?php
14if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.__DIR__ . '/../../pdo/tests/');
15require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
16$db = PDOTest::factory();
17switch ($db->getAttribute(PDO::ATTR_DRIVER_NAME)) {
18    case 'oci': $from = 'from dual'; break;
19    case 'firebird': $from = 'from rdb$database'; break;
20    default: $from = ''; break;
21}
22$statement = $db->prepare("SELECT NULL AS null_value, 0 AS zero, 1 AS one $from");
23$statement->execute();
24$row = $statement->fetch(PDO::FETCH_LAZY);
25var_dump(
26    empty($row->null_value),
27    empty($row->zero),
28    !empty($row->one),
29    empty($row->missing),
30    !isset($row->null_value),
31    isset($row->zero),
32    isset($row->one),
33    !isset($row->missing)
34);
35?>
36--EXPECT--
37bool(true)
38bool(true)
39bool(true)
40bool(true)
41bool(true)
42bool(true)
43bool(true)
44bool(true)
45