public function Post() { $this->DoBeforePost(); if ($this->editMode) { if (count($this->editFieldValues) > 0 || count($this->editFieldSetToDefault) > 0) { $updateCommand = $this->CreateUpdateCommand(); $primaryKeyValues = $this->GetOldPrimaryKeyValuesMap(); foreach ($primaryKeyValues as $keyFieldName => $value) { $updateCommand->SetKeyFieldValue($keyFieldName, $value); } foreach ($this->editFieldValues as $fieldName => $value) { if (in_array($fieldName, $this->editFieldSetToDefault)) { $updateCommand->SetParameterValue($fieldName, null, true); } else { $updateCommand->SetParameterValue($fieldName, $value); } } foreach ($this->GetFields() as $field) { if ($field->GetReadOnly()) { $updateCommand->SetParameterValue($field->GetNameInDataset(), $field->GetDefaultValue()); } } if (DebugUtils::GetDebugLevel() >= 1) { echo $updateCommand->GetSQL() . '<br>'; } $updateCommand->Execute($this->GetConnection()); } $this->editMode = false; } elseif ($this->insertMode) { $hasValuesForAutoIncrement = false; $insertCommand = $this->CreateInsertCommand() or RaiseError('Could not create InsertCommand'); $this->Connect(); foreach ($this->masterFieldValue as $fieldName => $value) { $insertCommand->SetParameterValue($fieldName, $value); } foreach ($this->insertFieldValues as $fieldName => $value) { if (in_array($fieldName, $this->insertFieldSetToDefault)) { if (!$this->GetFieldByName($fieldName)->GetIsAutoincrement()) { $insertCommand->SetParameterValue($fieldName, null, true); } } else { if ($this->GetFieldByName($fieldName)->GetIsAutoincrement()) { $hasValuesForAutoIncrement = true; } $insertCommand->SetParameterValue($fieldName, $value); } } foreach ($this->GetFields() as $field) { if ($field->GetReadOnly()) { $insertCommand->SetParameterValue($field->GetNameInDataset(), $field->GetDefaultValue()); } } foreach ($this->defaultFieldValues as $fieldName => $value) { $insertCommand->SetParameterValue($fieldName, $value); } $insertCommand->SetAutoincrementInsertion($hasValuesForAutoIncrement); if (DebugUtils::GetDebugLevel() == 1) { echo $insertCommand->GetSQL() . '<br>'; } $insertCommand->Execute($this->GetConnection()); $this->UpdatePrimaryKeyAfterInserting(); $this->insertMode = false; $this->insertedMode = true; } }
function RenderPage(Page $Page) { $this->SetHTTPContentTypeByPage($Page); $PageList = $Page->GetPageList(); $PageList = isset($PageList) ? $this->Render($PageList) : ''; $displayDebugInfo = DebugUtils::GetDebugLevel(); $inputValues = array('PageList' => $PageList, 'ErrorMessage' => $this->exception->getMessage(), 'DisplayDebugInfo' => $displayDebugInfo); if ($displayDebugInfo == 1) { $inputValues['File'] = $this->exception->getFile(); $inputValues['Line'] = $this->exception->getLine(); $inputValues['Trace'] = $this->exception->getTraceAsString(); } $this->DisplayTemplate('list/error_page.tpl', array('Page' => $Page), $inputValues); }