<?php
/**
 * @copyright (c) Kufer Software GmbH, Loisachstrasse 4, D-84453 Mühldorf
 */


class DBWorkDozWebDataCheck extends DBWorkGenerated
{
  public function __construct($pDBTyp = 1, $pNewInstance = false)
  {
    parent::__construct($pDBTyp, $pNewInstance);
    $this->select = 'nr, taetigkeitsbez, kuenstlername, profil, homepage';
    $this->_dataModulFields = array('taetigkeitsbez', 'kuenstlername', 'profil', 'homepage', 'id');
  }

  
  public function getNewObject()
  {
    return new DozWebDataCheck();
  }

  public function getTableName(): string
  {
    return 'doz_web_data_check';
  }

  
  public function translateVarName($varname)
  {
    switch ($varname) {
      default: return parent::translateVarName($varname);
      case 'id': return 'nr';
    }
  }

  public function getOrCreateDozWebDataCheck($pId, $pRefreshCache = false, $pDontProtocol = false, $pDmzBetrieb = false)
  {
    $result = $this->getOneNoFilter($pId, 'nr', $pRefreshCache);
    if (!isset($result->id)) {
      $result->id = $pId;
      $this->insertDozWebDataCheck($result, $pDontProtocol, $pDmzBetrieb);
    }

    return $result;
  }

  public function insertDozWebDataCheck($pDozWebDataCheck, $pDontProtocol = false, $pDmzBetrieb = false)
  {
    $sql = 'INSERT INTO ' . $this->getTableName() . ' (nr) VALUES (' . $pDozWebDataCheck->id . ')';
    $this->dboperation->clear();
    $this->dboperation->execute($sql);
    if (!$pDontProtocol) {
      $this->saveChanging($this->getTableName(), '', '', $pDozWebDataCheck->id, 'id', 'I', $pDmzBetrieb);
    }
    $this->setActionIDs();
  }

  
  public function updateDozWebDataCheck($pDozWebDataCheck, $pIsDmzBetrieb)
  {
    $orgDozWebDataCheck = $this->getOneNoFilter($pDozWebDataCheck->id, 'nr', true);
    $this->updateObject($pDozWebDataCheck, $orgDozWebDataCheck, $this->getTableName(), 'id', 'U', false, $pIsDmzBetrieb);
    $this->setActionIDs();
  }
}