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


class DBWorkHLDauer extends DBWorkHLBasis
{
  public function __construct($pDBTyp = 1, $pNewInstance = false)
  {
    parent::__construct($pDBTyp, $pNewInstance);
    $this->select = ' id, dauer ';
  }

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

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

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

    return $tmp;
  }

  
  public function getAll()
  {
    $sql = "SELECT $this->select FROM " . $this->getTableName();
    $this->dboperation->clear();
    $this->dboperation->query($sql);

    return $this->getAllRows();
  }

  
  public function getOne($pId)
  {
    $id = $this->dboperation->getInt4Sql($pId);
    $sql = "SELECT $this->select FROM " . $this->getTableName() . " WHERE id = '$id'";
    $this->dboperation->clear();
    $this->dboperation->query($sql);
    if ($this->dboperation->rowcount() == 0) {
      return false;
    }

    return $this->getFirstRow();
  }
}