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


class DBWorkHLBeziehung extends DBWorkGenerated
{
  public function __construct($pDBTyp = 1, $pNewInstance = false)
  {
    parent::__construct($pDBTyp, $pNewInstance);
    $this->select = 'id, bez1, bez2, art';
  }

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

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

  
  public function getCurrentRow($pRefreshCache = false)
  {
    $tmp = $this->getNewObject();

    $tmp->id = $this->getDatamodulValue('id');
    $tmp->bez1 = $this->getDatamodulValue('bez1');
    $tmp->bez2 = $this->getDatamodulValue('bez2');
    $tmp->art = $this->getDatamodulValue('art');

    return $tmp;
  }

  
  public function getByBez1AndBez2($pBezeichnung1, $pBezeichnung2)
  {
    $bez1 = $this->dboperation->getString4Sql($pBezeichnung1);
    $bez2 = $this->dboperation->getString4Sql($pBezeichnung2);
    $sql = "SELECT $this->select FROM " . $this->getTableName() . " WHERE bez1='$bez1' AND bez2='$bez2' AND " . $this->dboperation->dbparser->isNull('inaktiv', '\'F\'') . " != 'W'";

    $this->dboperation->clear();
    $this->dboperation->query($sql);

    return $this->getFirstRow(false);
  }
}