Esempio n. 1
0
 function Select($p_oSession)
 {
     $this->m_nError = $this->m_nDBO_OK;
     $bFirst = true;
     $this->m_bBof = true;
     $this->m_bEof = true;
     if ($p_oSession->GetFileRead()) {
         $oFile = @fopen($p_oSession->GetDatabase() . $this->m_sTABLE_NAME . ".dat", "r");
         if ($oFile == 0) {
             $this->m_nError = $this->m_nDBO_BAD_READ_FILE;
             $this->m_sErrorInfo = $this->m_sTABLE_NAME . ".dat";
             return false;
         }
         while (!feof($oFile)) {
             if ($this->ReadRecord($oFile, $p_oSession, $sData)) {
                 if ($this->MatchCriteria($sData, false)) {
                     if ($bFirst) {
                         $this->m_oTable = array();
                         $bFirst = false;
                         $this->m_bBof = false;
                         $this->m_bEof = false;
                     }
                     $oObj = new CRowtblcompleted();
                     if ($sData[0] != "") {
                         $oObj->SetCompletedId($sData[0]);
                     }
                     if ($sData[1] != "") {
                         $oObj->SetPendingId($sData[1]);
                     }
                     if ($sData[2] != "") {
                         $oObj->SetCommandId($sData[2]);
                     }
                     if ($sData[3] != "") {
                         $oObj->SetInXML($sData[3]);
                     }
                     if ($sData[4] != "") {
                         $oObj->SetOutXML($sData[4]);
                     }
                     if ($sData[5] != "") {
                         $oObj->SetInTimestamp($sData[5]);
                     }
                     if ($sData[6] != "") {
                         $oObj->SetExecTimestamp($sData[6]);
                     }
                     if ($sData[7] != "") {
                         $oObj->SetSource($sData[7]);
                     }
                     if ($sData[8] != "") {
                         $oObj->SetSuccess($sData[8]);
                     }
                     if ($sData[9] != "") {
                         $oObj->SetMode($sData[9]);
                     }
                     if ($sData[10] != "") {
                         $oObj->SetData($sData[10]);
                     }
                     array_push($this->m_oTable, $oObj);
                 }
             }
         }
         if (!$bFirst) {
             reset($this->m_oTable);
             $oRow = current($this->m_oTable);
             if ($sData[0] != "") {
                 $this->m_nCompletedId = $oRow->GetCompletedId();
             }
             if ($sData[1] != "") {
                 $this->m_nPendingId = $oRow->GetPendingId();
             }
             if ($sData[2] != "") {
                 $this->m_nCommandId = $oRow->GetCommandId();
             }
             if ($sData[3] != "") {
                 $this->m_sInXML = $oRow->GetInXML();
             }
             if ($sData[4] != "") {
                 $this->m_sOutXML = $oRow->GetOutXML();
             }
             if ($sData[5] != "") {
                 $this->m_dInTimestamp = $oRow->GetInTimestamp();
             }
             if ($sData[6] != "") {
                 $this->m_dExecTimestamp = $oRow->GetExecTimestamp();
             }
             if ($sData[7] != "") {
                 $this->m_nSource = $oRow->GetSource();
             }
             if ($sData[8] != "") {
                 $this->m_nSuccess = $oRow->GetSuccess();
             }
             if ($sData[9] != "") {
                 $this->m_sMode = $oRow->GetMode();
             }
             if ($sData[10] != "") {
                 $this->m_bData = $oRow->GetData();
             }
         }
         fclose($oFile);
     } else {
         $sSql = "SELECT * FROM " . $this->m_sTABLE_NAME;
         if ($this->GenerateWhereClause($p_oSession, false, $sWhere)) {
             $sSql .= $sWhere;
         } else {
             $this->m_nError = $this->m_nDBO_DATATYPE;
             $this->m_sErrorInfo = $sWhere;
             return false;
         }
         if (strlen($this->m_sSortBy)) {
             $sSql .= " ORDER BY " . $this->m_sSortBy;
         }
         if ($this->m_nFromRecord != 0) {
             $sSql .= " LIMIT " . $this->m_nFromRecord . "," . $this->m_nMaxRecords;
         } else {
             if ($this->m_nMaxRecords != -1) {
                 $sSql .= " LIMIT " . $this->m_nMaxRecords;
             }
         }
         if (!$this->CheckSession($p_oSession)) {
             $this->m_nError = $this->m_nDBO_BAD_SESSION;
             return false;
         } else {
             if (!($oResult = mysql_query($sSql, $p_oSession->GetLink()))) {
                 $this->m_nError = $this->m_nDBO_SELECT_FAILURE;
                 $this->m_sErrorInfo = mysql_error() . ":" . $sSql;
                 return false;
             } else {
                 while ($oRow = mysql_fetch_object($oResult)) {
                     $oObj = new CRowtblcompleted();
                     if ($bFirst) {
                         $this->m_oTable = array();
                         if (!is_null($oRow->CompletedId)) {
                             $this->m_nCompletedId = $oRow->CompletedId;
                         }
                         if (!is_null($oRow->PendingId)) {
                             $this->m_nPendingId = $oRow->PendingId;
                         }
                         if (!is_null($oRow->CommandId)) {
                             $this->m_nCommandId = $oRow->CommandId;
                         }
                         if (!is_null($oRow->InXML)) {
                             $this->m_sInXML = $oRow->InXML;
                         }
                         if (!is_null($oRow->OutXML)) {
                             $this->m_sOutXML = $oRow->OutXML;
                         }
                         if (!is_null($oRow->InTimestamp)) {
                             $this->m_dInTimestamp = $oRow->InTimestamp;
                         }
                         if (!is_null($oRow->ExecTimestamp)) {
                             $this->m_dExecTimestamp = $oRow->ExecTimestamp;
                         }
                         if (!is_null($oRow->Source)) {
                             $this->m_nSource = $oRow->Source;
                         }
                         if (!is_null($oRow->Success)) {
                             $this->m_nSuccess = $oRow->Success;
                         }
                         if (!is_null($oRow->Mode)) {
                             $this->m_sMode = $oRow->Mode;
                         }
                         if (!is_null($oRow->Data)) {
                             $this->m_bData = $oRow->Data;
                         }
                         $bFirst = false;
                         $this->m_bBof = false;
                         $this->m_bEof = false;
                     }
                     if (!is_null($oRow->CompletedId)) {
                         $oObj->SetCompletedId($oRow->CompletedId);
                     }
                     if (!is_null($oRow->PendingId)) {
                         $oObj->SetPendingId($oRow->PendingId);
                     }
                     if (!is_null($oRow->CommandId)) {
                         $oObj->SetCommandId($oRow->CommandId);
                     }
                     if (!is_null($oRow->InXML)) {
                         $oObj->SetInXML($oRow->InXML);
                     }
                     if (!is_null($oRow->OutXML)) {
                         $oObj->SetOutXML($oRow->OutXML);
                     }
                     if (!is_null($oRow->InTimestamp)) {
                         $oObj->SetInTimestamp($oRow->InTimestamp);
                     }
                     if (!is_null($oRow->ExecTimestamp)) {
                         $oObj->SetExecTimestamp($oRow->ExecTimestamp);
                     }
                     if (!is_null($oRow->Source)) {
                         $oObj->SetSource($oRow->Source);
                     }
                     if (!is_null($oRow->Success)) {
                         $oObj->SetSuccess($oRow->Success);
                     }
                     if (!is_null($oRow->Mode)) {
                         $oObj->SetMode($oRow->Mode);
                     }
                     if (!is_null($oRow->Data)) {
                         $oObj->SetData($oRow->Data);
                     }
                     array_push($this->m_oTable, $oObj);
                 }
                 mysql_free_result($oResult);
             }
         }
     }
     return true;
 }