Hi i am currntly creating a script to get data out of a odbc connection and store it in an array at the moment i get this error, i have another function called Data that does the same thing but does not put the data in to an array and that one works fine, i'm not sure what i'm doing wrong any help would be appreciated.
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 36 bytes) in
I have a similar function to this the Cycle function but it is not putting the data in to an array and it works perfectly here is that code
Public function Data() {
$sql = "SELECT TOP 1 ReaderData.ReaderIndex, ReaderData.CardID, ReaderData.ReaderDate, ReaderData.ReaderTime, ReaderData.controllerID, Left([dtReading],10) AS [date], ReaderData.dtReading FROM ReaderData
WHERE ReaderData.controllerID=$this->Id AND ReaderData.CardID = 'FFFFFFF0 '
ORDER BY ReaderData.ReaderIndex DESC;";
$rs = $this->Db($sql,"dtReading");
while ($rs) {
$this->DtReading = $rs;
$result = strtotime($this->DtReading) + 2 * 60 * 60;
$this->time = time() + 60 * 60 - $result;
return round($this->time / 60, 2);
}
}
This is the function with the error
public function Cycle() {
$sql = "SELECT TOP 2 ReaderData.ReaderIndex, ReaderData.CardID, ReaderData.ReaderDate, ReaderData.ReaderTime, ReaderData.controllerID, Left([dtReading],10) AS [date], ReaderData.dtReading FROM ReaderData WHERE ReaderData.controllerID=$this->Id AND ReaderData.CardID = 'FFFFFFF0 ' ORDER BY ReaderData.ReaderIndex DESC;";
$rs = $this->Db($sql,"dtReading");
$data = array();
while ($rs) {
$data[] = $this->DtReading = $rs;
}
// var_dump($data);
$this->Time1 = ($data[0]);
$this->Time2 = ($data[1]);
$Time1E = strtotime($this->Time1) + 2 * 60 * 60;
$Time2E = strtotime($this->Time2) + 2 * 60 * 60;
$this->cycle = $Time1E - $Time2E;
return round($this->cycle, 2);
This is the Db connect function
Public function Db($sql,$index) {
$conn = new database_odbc('monitor', '', '');
$rs = $conn->justquery($sql);
while (odbc_fetch_row($rs)) {
$result = $this->val = odbc_result($rs, $index);
return $result;
}
Here is a Var_dump from $rs in the cycle function
string(23) "2014-07-22 06:20:30.000"
.......string(23) "2014-07-22 11:49:00.000"
.......string(23) "2014-07-22 11:52:26.000"
.......string(23) "2014-07-22 10:48:59.000"
.......string(23) "2014-07-22 11:52:24.000"
.......string(23) "2014-07-22 11:49:09.000"
.......string(23) "2014-07-22 11:52:30.000"
.......string(23) "2014-07-22 11:53:30.000"
.......string(23) "2014-07-22 11:54:53.000"
.......string(23) "2014-07-22 11:52:38.000"
.......string(23) "2014-07-19 13:19:21.000"
.......string(23) "2014-07-22 11:23:58.000"
.......string(23) "2014-07-21 13:33:06.000"
.......string(23) "2014-06-23 11:15:43.000"