hi i have a function that gets Data from an ODBC connection
public function SageData() {
$this->Arr = array();
$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->Cycletime = odbc_result($rs, "cycletime");
}
odbc_close($conn);
return round($this->Cycletime, 2);
}
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