xref: /PHP-5.6/ext/pdo/tests/bug_60665.phpt (revision 7938ebf6)
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();
16
17$statement = $db->prepare("SELECT NULL AS null_value, 0 AS zero, 1 AS one");
18$statement->execute();
19$row = $statement->fetch(PDO::FETCH_LAZY);
20var_dump(
21    empty($row->null_value),
22    empty($row->zero),
23    !empty($row->one),
24    empty($row->missing),
25    !isset($row->null_value),
26    isset($row->zero),
27    isset($row->one),
28    !isset($row->missing)
29);
30?>
31===DONE===
32--EXPECT--
33bool(true)
34bool(true)
35bool(true)
36bool(true)
37bool(true)
38bool(true)
39bool(true)
40bool(true)
41===DONE===
42