Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php db2_fetch_object():在strsql中执行查询时引发的获取失败_Php_Db2_Db2 400 - Fatal编程技术网

Php db2_fetch_object():在strsql中执行查询时引发的获取失败

Php db2_fetch_object():在strsql中执行查询时引发的获取失败,php,db2,db2-400,Php,Db2,Db2 400,在PHP中运行查询时出现以下错误: 警告:db2_fetch_object():在。。。第15行 奇怪的是,当我使用strsql在I5终端上运行相同的查询时,它工作了,我得到了一个很好的记录集。我运行的查询是从表(U8.feedconst(0))中选择*作为t1 U8.feedconst(0)是一个表函数,驻留在U8库中,但从用户库中提取数据。当我使用IBM终端时,我将用户的库设置为uasetlibl。该库在PHP DB2连接中的$this->user->library中指定(该库已成功用于其他

在PHP中运行查询时出现以下错误:

警告:db2_fetch_object():在。。。第15行

奇怪的是,当我使用
strsql
在I5终端上运行相同的查询时,它工作了,我得到了一个很好的记录集。我运行的查询是
从表(U8.feedconst(0))中选择*作为t1

U8.feedconst(0)
是一个表函数,驻留在U8库中,但从用户库中提取数据。当我使用IBM终端时,我将用户的库设置为
uasetlibl
。该库在PHP DB2连接中的$this->user->library中指定(该库已成功用于其他查询)

以下是PHP代码:

$this->conn = db2_connect(
        \HOST, 
        $this->user->username, 
        $this->user->password,
        array('i5_libl' => $this->user->library . ' ' . \PROD_LIB,
            'i5_naming' => DB2_I5_NAMING_ON)
);
$sql = 'SELECT * FROM TABLE(U8.feedconst(0)) AS t1';
$stmt = db2_prepare($this->conn, $sql);
if ($stmt) {
    $this->user->log('stmt = ' . strval($stmt), true);
    $exec = db2_execute($stmt);
    if ($exec) {
        $this->user->log('exec = ' . strval($exec), true);
        $this->user->log('db2_stmt_errormsg = ' . db2_stmt_errormsg($stmt), true);
        while ($row = db2_fetch_object($stmt)) {
            $this->user->log($sql, true);
        }
    }
}
日志显示一切正常,直到
db2\u fetch\u object()
行:

2015-11-18 10:43:53pm : stmt = Resource id #21
2015-11-18 10:43:53pm : exec = 1
2015-11-18 10:54:27pm : db2_stmt_errormsg = 
如您所见,我尝试使用
DB2\u stmt\u errormsg()
从DB2获取真正的错误,但它没有返回任何内容


我看了其他类似的问题,如和,但它们似乎没有解决我的情况。

我找到了我悲伤的原因。似乎有一个额外的库被table函数内部使用。由于该表函数在另一个库中有依赖项,而另一个库不包括在我的库列表中,因此返回给PHP的记录集是空的

它在i5终端中工作,因为我的终端会话已经设置为将另一个库包含在它的库列表中,我不知道

当我在连接中将另一个内部库添加到我的库列表中时,查询在PHP中工作得很好

如果其他任何人遇到此问题,请确保包含查询使用的所有库,包括任何可能是内部依赖项的库