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 CRowtblconfig();
                     if ($sData[0] != "") {
                         $oObj->SetConfigId($sData[0]);
                     }
                     if ($sData[1] != "") {
                         $oObj->SetParam($sData[1]);
                     }
                     if ($sData[2] != "") {
                         $oObj->SetValue($sData[2]);
                     }
                     if ($sData[3] != "") {
                         $oObj->SetDescription($sData[3]);
                     }
                     if ($sData[4] != "") {
                         $oObj->SetModifiable($sData[4]);
                     }
                     array_push($this->m_oTable, $oObj);
                 }
             }
         }
         if (!$bFirst) {
             reset($this->m_oTable);
             $oRow = current($this->m_oTable);
             if ($sData[0] != "") {
                 $this->m_nConfigId = $oRow->GetConfigId();
             }
             if ($sData[1] != "") {
                 $this->m_sParam = $oRow->GetParam();
             }
             if ($sData[2] != "") {
                 $this->m_sValue = $oRow->GetValue();
             }
             if ($sData[3] != "") {
                 $this->m_sDescription = $oRow->GetDescription();
             }
             if ($sData[4] != "") {
                 $this->m_bModifiable = $oRow->GetModifiable();
             }
         }
         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 CRowtblconfig();
                     if ($bFirst) {
                         $this->m_oTable = array();
                         if (!is_null($oRow->ConfigId)) {
                             $this->m_nConfigId = $oRow->ConfigId;
                         }
                         if (!is_null($oRow->Param)) {
                             $this->m_sParam = $oRow->Param;
                         }
                         if (!is_null($oRow->Value)) {
                             $this->m_sValue = $oRow->Value;
                         }
                         if (!is_null($oRow->Description)) {
                             $this->m_sDescription = $oRow->Description;
                         }
                         if (!is_null($oRow->Modifiable)) {
                             $this->m_bModifiable = $oRow->Modifiable;
                         }
                         $bFirst = false;
                         $this->m_bBof = false;
                         $this->m_bEof = false;
                     }
                     if (!is_null($oRow->ConfigId)) {
                         $oObj->SetConfigId($oRow->ConfigId);
                     }
                     if (!is_null($oRow->Param)) {
                         $oObj->SetParam($oRow->Param);
                     }
                     if (!is_null($oRow->Value)) {
                         $oObj->SetValue($oRow->Value);
                     }
                     if (!is_null($oRow->Description)) {
                         $oObj->SetDescription($oRow->Description);
                     }
                     if (!is_null($oRow->Modifiable)) {
                         $oObj->SetModifiable($oRow->Modifiable);
                     }
                     array_push($this->m_oTable, $oObj);
                 }
                 mysql_free_result($oResult);
             }
         }
     }
     return true;
 }