dregduc63699 2014-07-17 08:39
浏览 19

Php函数在第7个值后停止

hi i have a function that gets Data from an ODBC connection

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].[cycletime]
FROM [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->SageCycle = odbc_result($rs, "cycletime");
    }
  //  var_dump($this->SageCycle);
    odbc_close($conn);
    return $this->SageCycle;
}

This function is part of a class below is the code to create a new object in the class, In the function the $this->name corresponds to the ZW01001 and so on numbers

Machinecycle("ZW01001", "ZW01001Percent", 0);
Machinecycle("ZW01004", "ZW01004Percent", 1);
Machinecycle("ZW01005", "ZW01005Percent", 2);

the function is called by another function in the class to turn the data in to a percentage i can use see below

public function GetM() {

    $q = $this->Cycle();
    $qq = $this->SageData();

    $this->M = $q - $qq;
  //  $this->P = $this->M / $this->sageData();

    if ($qq == 0) {
        $this->P = 0;
    } else {
        $this->P = $this->M / $this->sageData();
    }

    return round($this->P, 2);
}

The Values outputted by GetM are put in to an array, my problem is that when i run this i get the data for the first 7 out of 14 objects and this error for the rest of them

Notice: Undefined property: machine::$Cycletime in C:\Somepath\Datatest.php on line 104

Line 104 is this part

    return round($this->Cycletime, 2);

What i do not understand is why it is doing this after the first 7 and failing on the rest the data is there

to clarify there are 14 instances of the class and it works for the first 7 and then stops after those.

Here is the entire class for Machines It's a real mess but here it is www.pastebin.com/LMk2gvWG This might help debug it When i echo the Sql i get this pastebin.com/13nufXYt for some reason 1-9 are are repeated but those are the ones that work it's the once that are not repeated that dont work

  • 写回答

1条回答 默认 最新

  • douxi5940 2014-07-17 09:02
    关注

    Could you post the code of class 'machine'? Maybe somewhere the variable is replaced by other class object.

    评论

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大