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
Could you post the code of class 'machine'? Maybe somewhere the variable is replaced by other class object.