dsgdhtr_43654 2013-01-17 03:00 采纳率: 100%
浏览 38

在PHP中总结两个Pervsive SQL语句

I am running a script that does MANY things but I am trying to get a Pervasive statement to work in my php that works in the DB that I am querying. I have tried all my tricks, but have had no success with getting this to work in the table that this is supposed to be displayed in.

$pom = $dbx->getOne('SELECT (SELECT SUM(wrt_sls) FROM wrt 
        WHERE wrt_cat = \'POM\' 
        AND wrt_cng_dat_4 >= '.$start.' 
        AND wrt_cng_dat_4 <= '.$end.' 
        AND wrt_pft_ctr in '.$pcs.') +
        (SELECT SUM(wrt_sls) FROM wrt 
        WHERE wrt_cat in (\'BED\',\'MP\')
        AND wrt_vend_id = \'PROTECTABED\' 
        AND wrt_cng_dat_4 >= '.$start.' 
        AND wrt_cng_dat_4 <= '.$end.' 
        AND wrt_pft_ctr in '.$pcs);

Again, I get the right result in Pervasive but am getting nothing in the actual application. Any tips?

  • 写回答

2条回答 默认 最新

  • douhanzhuo6905 2013-01-17 03:21
    关注

    The first thing I would check is the values of $start, $end, and $pcs. For example, the way you are using them they appear to be INT values. However, if the columns in the table are not of type INT, then they are not quoted correctly in your query. I also do not see the ending ) that will be required in your query to work correctly. You may need to rewrite your query like:

    $pom = $dbx->getOne("SELECT (SELECT SUM(wrt_sls) FROM wrt 
            WHERE wrt_cat = 'POM' 
            AND wrt_cng_dat_4 >= '" . $start . "' 
            AND wrt_cng_dat_4 <= '" . $end . "' 
            AND wrt_pft_ctr in '" . $pcs . "') +
            (SELECT SUM(wrt_sls) FROM wrt 
            WHERE wrt_cat in ('BED','MP')
            AND wrt_vend_id = 'PROTECTABED' 
            AND wrt_cng_dat_4 >= '" . $start . "' 
            AND wrt_cng_dat_4 <= '" . $end . "' 
            AND wrt_pft_ctr in '" . $pcs ."')");
    
    评论

报告相同问题?

悬赏问题

  • ¥15 mmocr的训练错误,结果全为0
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀