duanji5116 2014-07-16 11:02
浏览 8

功能只有一半工作不确定为什么

i have a function that is part of a class in php to get some data, it seems to be working for some but not others

i have an issue where it will get the first 6 or so records and the just return the rest as null Here is the Var_dump $this->sdata

string(6) "86.544" 
Notice: Undefined property: machine::$sdata in C:\Documents and Settings\jKirkpatrick\My Documents\xammp\htdocs\Datatest.php on line 96
NULL 
string(16) "181.090909090909" 
string(5) "0.072" 
string(3) "0.0" 
string(7)   "119.952"
string(3) "0.0" 
Notice: Undefined property: machine::$sdata in C:\Documents and  Settings\jKirkpatrick\My Documents\xammp\htdocs\Datatest.php on line 96
NULL 
Notice: Undefined property: machine::$sdata in C:\Documents and Settings\jKirkpatrick\My Documents\xammp\htdocs\Datatest.php on line 96
NULL 
Notice: Undefined property: machine::$sdata in C:\Documents and Settings\jKirkpatrick\My Documents\xammp\htdocs\Datatest.php on line 96
NULL 
Notice: Undefined property: machine::$sdata in C:\Documents and Settings\jKirkpatrick\My Documents\xammp\htdocs\Datatest.php on line 96
NULL 
Notice: Undefined property: machine::$sdata in C:\Documents and Settings\jKirkpatrick\My Documents\xammp\htdocs\Datatest.php on line 96
NULL 
Notice: Undefined property: machine::$sdata in C:\Documents and   Settings\jKirkpatrick\My Documents\xammp\htdocs\Datatest.php on line 96
NULL


public function SageData() {
    $conn = odbc_connect('DATA HUB', '', '');
    if (!$conn) {
        exit("Connection Failed: " . $conn);
    }
    $sql = "SELECT `SHOP FLOOR PRODUCTION PLAN`.MACHINE, `SHOP FLOOR PRODUCTION     

PLAN`.CODE, `SHOP FLOOR PRODUCTION PLAN`.DESCRIPTION, `SHOP FLOOR PRODUCTION     
PLAN`.WONo, `SHOP FLOOR PRODUCTION PLAN`.Quantity, `SHOP FLOOR PRODUCTION 
PLAN`.cycletime, `SHOP FLOOR PRODUCTION PLAN`.IMPS, `SHOP FLOOR PRODUCTION 
PLAN`.Estimate
FROM `P:\ProductionControl\Production Planning\DATA HUB.mdb`.`SHOP FLOOR PRODUCTION   
PLAN` `SHOP FLOOR PRODUCTION PLAN`

WHERE [SHOP FLOOR PRODUCTION PLAN].[MACHINE]='$this->name' ";
$rs = odbc_exec($conn, $sql);
    if (!$rs) {
        exit("Error in SQL");
    }
    while (odbc_fetch_row($rs)) {
        $this->sdata = $this->SDtReading = odbc_result($rs, "cycletime");
    }
    return@ $this->sdata;
}

the data is there here are the expected results

86.544
181.0909091
0.072
0
119.952
0 
72
32.76
799.992 
36
39.6
29.988

The function is part of a class and run as Machinecycle("ZW01001", "ZW01001Percent", 0);
in the query $this->name would be "ZW01001"

And help as to debugging this would be greatly appreciated

    while (odbc_fetch_row($rs)) {
        $this->sdata = $this->SDtReading = odbc_result($rs, "cycletime");
           var_dump($this->sdata);
        }
    return $this->sdata;
}

This with the Var dump in the while loop produces the same results as posted before without the NULL's

    while (odbc_fetch_row($rs)) {
        $this->sdata = $this->SDtReading = odbc_result($rs, "cycletime");
        }
    var_dump($this->sdata);
    return $this->sdata;
}

This with the Dump out side the While produces the results exactly as posted before.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 報錯:Person is not mapped,如何解決?
    • ¥15 c++头文件不能识别CDialog