我有一个函数,它是php中一个类的一部分来获取一些数据,它似乎适用于一些但不适用于其他人
我有一个问题,它将获得前6个左右的记录,然后将其余部分返回为null这里是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;
}
这里的数据是预期的结果
86.544
181.0909091
0.072
0
119.952
0
72
32.76
799.992
36
39.6
29.988
该功能是一个类的一部分,并作为Machinecycle运行(" ZW01001"," ZW01001Percent",0);
在查询$ this->名称中将是" ZW01001"
有关调试的帮助将非常感激
while (odbc_fetch_row($rs)) {
$this->sdata = $this->SDtReading = odbc_result($rs, "cycletime");
var_dump($this->sdata);
}
return $this->sdata;
}
这与while循环中的Var转储产生的结果与之前发布的结果相同,没有NULL&#39>
while (odbc_fetch_row($rs)) {
$this->sdata = $this->SDtReading = odbc_result($rs, "cycletime");
}
var_dump($this->sdata);
return $this->sdata;
}
对于Dump out侧,While产生的结果与之前发布的完全相同。