简体   繁体   English

通过 PHP 进行的 DB2 SQL 查询不返回结果

[英]DB2 SQL Query via PHP not returning results

Scratching my head as to why the below code won't work, needs some fresh eyes.抓挠我的脑袋为什么下面的代码不起作用,需要一些新的眼光。 Have tested SQL query in RazorSQL and it returns values but I can't get this to work in php.已经在 RazorSQL 中测试了 SQL 查询并返回值,但我无法让它在 php 中工作。 No connection or statement errors either.也没有连接或语句错误。 My guess is that this has something to do with 'i5_libl' but I haven't found any workarounds.我的猜测是这与“i5_libl”有关,但我还没有找到任何解决方法。 Any ideas?有任何想法吗?

<?php

class employees
{
    private $employees = array();
    private $db_host = '*LOCAL';
    private $db_options = array(
        'i5_naming' => DB2_I5_NAMING_ON,
        'i5_libl' => 'CLTDTA CLTPAY'
    );
    
    public function getList() {
        $connection = db2_connect($this->db_host,$GLOBALS['db_user'],$GLOBALS['db_password'],$this->db_options);
        echo db2_conn_error();
        echo db2_conn_errormsg();
        $sql='SELECT F0101.ABAN8, F0101.ABALPH FROM F0101 INNER JOIN FP0102 ON F0101.ABAN8=FP0102.VEAN8 WHERE FP0102.VESTAT=\'\'';
        $stmt= db2_prepare($connection,$sql);
        echo db2_stmt_error();
        echo db2_stmt_errormsg();
        $result= db2_execute($stmt);
        while ($row = db2_fetch_assoc($stmt)) {
            echo $row['ABAN8']; 
        }
        db2_close($connection);
        return true;            
    }
    
}
?>

!! !! Update:更新:

I tried switching DB2_I5_NAMING_ON and DB2_I5_NAMING_OFF, with corrections to query, still nothing.我尝试切换 DB2_I5_NAMING_ON 和 DB2_I5_NAMING_OFF,对查询进行更正,但仍然没有。 Seems to me that this has more to do with the specific library (CLTDTA).在我看来,这更多地与特定库(CLTDTA)有关。 When I run a vanilla SELECT query on just CLTPAY, I get a result fine.当我只在 CLTPAY 上运行一个普通的 SELECT 查询时,我得到的结果很好。 When I try the equivalent on CLTDTA, I don't get a result.当我在 CLTDTA 上尝试等效项时,我没有得到结果。 The user, uses the system library list which contains references to all relevant libraries including CLTDTA.用户使用系统库列表,其中包含对包括 CLTDTA 在内的所有相关库的引用。

The errors are being echoed for each step being performed except for the execute.除了执行之外,正在执行的每个步骤都会回显错误。 Add those same requests after the EXECUTE, just like is being done after the CONNECT and PREPARE steps.在 EXECUTE 之后添加相同的请求,就像在 CONNECT 和 PREPARE 步骤之后所做的一样。

If still nothing obvious, turn on the debug messaging feature [via the connection, by Start Service Job (STRSRVJOB) then Start Debug (STRDBG) on the job servicing the connection, or using the QAQQINI capabilities] and review the joblog for the job servicing the connection.如果仍然不明显,请打开调试消息功能 [通过连接,通过启动服务作业 (STRSRVJOB) 然后启动调试 (STRDBG) 在服务连接的作业上,或使用 QAQQINI 功能] 并查看作业服务的作业日志连接。 Probably might just as well start a detailed database monitoring too;也许也可以开始详细的数据库监控; Start Database Monitor (STRDBMON) to verify the incoming statements.启动数据库监视器 (STRDBMON) 以验证传入的语句。 If still nothing is obvious from those, then also get a job trace, and then verify from the trace data [ie the effective debug trace DATA-records vs the execution FLOW-records], that the proper\\expected files are being opened by the query request.如果仍然没有什么是明显的,那么也得到一个作业跟踪,然后从跟踪数据中验证[即有效的调试跟踪数据记录与执行流记录],正确的\\预期的文件正在被打开查询请求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM