Example #1
0
 public function saveReligion()
 {
     $this->log->showLog(2, "Access saveReligion()");
     // die;
     global $xoopsDB, $saveHandler, $createdby, $timestamp, $defaultorganization_id;
     $tablename = "sim_religion";
     $pkey = "religion_id";
     $keyword = "Religion";
     $controlfieldname = "religion_name";
     $insertCount = $saveHandler->ReturnInsertCount();
     $this->log->showLog(3, "Start Insert({$insertCount} records)");
     if ($insertCount > 0) {
         $arrfield = array($controlfieldname, "religion_description", "isactive", "defaultlevel", "created", "createdby", "updated", "updatedby", "organization_id");
         $arrfieldtype = array('%s', '%s', '%d', '%d', '%s', '%d', '%s', '%d', '%d');
         // Yes there are INSERTs to perform...
         for ($currentRecord = 0; $currentRecord < $insertCount; $currentRecord++) {
             $arrvalue = array($saveHandler->ReturnInsertField($currentRecord, $controlfieldname), $saveHandler->ReturnInsertField($currentRecord, "religion_description"), $saveHandler->ReturnInsertField($currentRecord, "isactive"), $saveHandler->ReturnInsertField($currentRecord, "defaultlevel"), $timestamp, $createdby, $timestamp, $createdby, $defaultorganization_id);
             $controlvalue = $saveHandler->ReturnInsertField($currentRecord, $controlfieldname);
             $this->InsertRecord($tablename, $arrfield, $arrvalue, $arrfieldtype, $controlvalue, $pkey);
             // Now we execute this query
         }
     }
     $updateCount = $saveHandler->ReturnUpdateCount();
     $this->log->showLog(3, "Start update({$updateCount} records)");
     if ($updateCount > 0) {
         $arrfield = array($controlfieldname, "religion_description", "isactive", "defaultlevel", "updated", "updatedby", "isdeleted");
         $arrfieldtype = array('%s', '%s', '%d', '%d', '%s', '%d', '%d');
         // Yes there are UPDATEs to perform...
         for ($currentRecord = 0; $currentRecord < $updateCount; $currentRecord++) {
             $arrvalue = array($saveHandler->ReturnUpdateField($currentRecord, $controlfieldname), $saveHandler->ReturnUpdateField($currentRecord, "religion_description"), $saveHandler->ReturnUpdateField($currentRecord, "isactive"), $saveHandler->ReturnUpdateField($currentRecord, "defaultlevel"), $timestamp, $createdby, $saveHandler->ReturnUpdateField($currentRecord, "isdeleted"));
             $controlvalue = $saveHandler->ReturnUpdateField($currentRecord, $controlfieldname);
             $this->UpdateRecord($tablename, $pkey, $saveHandler->ReturnUpdateField($currentRecord), $arrfield, $arrvalue, $arrfieldtype, $controlvalue);
         }
     }
     $ispurge = 0;
     $deleteCount = $saveHandler->ReturnDeleteCount();
     $this->log->showLog(3, "Start delete/purge({$deleteCount} records)");
     $classname = "class/{$keyword}.inc.php";
     include $classname;
     $this->log->showLog(3, "Include {$classname} successfully");
     $o = new Religion();
     $this->log->showLog(3, "Inilialize Religion()");
     if ($deleteCount > 0) {
         for ($currentRecord = 0; $currentRecord < $deleteCount; $currentRecord++) {
             $record_id = $saveHandler->ReturnDeleteField($currentRecord);
             $o->fetchReligion($record_id);
             $controlvalue = $o->religion_name;
             $isdeleted = $o->isdeleted;
             if ($o->allowDelete($record_id)) {
                 $this->DeleteRecord($tablename, $pkey, $record_id, $controlvalue, $isdeleted);
             } else {
                 $this->failfeedback .= "Cannot delete {$keyword}: {$o->religion_name} <br/>";
             }
         }
     }
     //$this->failfeedback.="asdasdpasd<br/>\n";
     //$this->failfeedback.="123 3443<br/>\n";
     //$this->failfeedback.="234 45656523 234<br/>\n";
     if ($this->failfeedback != "") {
         $this->failfeedback .= "Warning!<br/>\n" . $this->failfeedback;
     }
     $saveHandler->setErrorMessage($this->failfeedback);
     $saveHandler->CompleteSave();
 }