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


class DBWorkHLStatusKZ extends DBWorkHLBasis
{
  protected static $_cache_Anmeldestati;

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

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

  
  public function getCurrentRow($pRefreshCache = false)
  {
    $tmp = $this->getNewObject();
    $tmp->id = $this->getDatamodulValue('id');
    $tmp->kennz = $this->getDatamodulValue('kennz');
    $tmp->text = $this->getDatamodulValue('text');

    return $tmp;
  }

  
  public function getAll($pRefreshCache = false)
  {
    if ($pRefreshCache || !isset(self::$_cache_Anmeldestati)) {
      $this->dboperation->clear();
      $this->dboperation->query('SELECT id,kennz,text FROM statuskz');

      self::$_cache_Anmeldestati = $this->getAllRows();
    }

    return self::$_cache_Anmeldestati;
  }

  
  public function getAllKennzArray($pOhneLeer = false)
  {
    $this->dboperation->clear();
    $this->dboperation->query('SELECT kennz FROM statuskz');

    $result = array();
    $rowcount = $this->dboperation->rowcount();
    for ($i = 0; $i < $rowcount; $i++) {
      $this->dboperation->selectrow($i);
      if (!($pOhneLeer && $this->getDatamodulValue('kennz') == '')) {
        $result[] = $this->getDatamodulValue('kennz');
      }
    }

    return $result;
  }

  
  public function getAllKennzTextArray($pOhneLeer = false)
  {
    $this->dboperation->clear();
    $this->dboperation->query('SELECT kennz, text FROM statuskz');

    $result = array();
    $rowcount = $this->dboperation->rowcount();
    for ($i = 0; $i < $rowcount; $i++) {
      $this->dboperation->selectrow($i);
      if (!($pOhneLeer && $this->getDatamodulValue('kennz') == '')) {
        $result[$this->getDatamodulValue('kennz')] = $this->getDatamodulValue('text');
      }
    }

    return $result;
  }

  
  public function getOne($pId)
  {
    $id = $this->dboperation->getInt4Sql($pId);
    $this->dboperation->clear();
    $this->dboperation->query("SELECT id,kennz,text FROM statuskz WHERE id='" . $id . "'");

    return $this->getFirstRow();
  }
}