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


class DBWorkHLSonderwunsch extends DBWork
{
  public function __construct($pDBTyp = 1, $pNewInstance = false)
  {
    parent::__construct($pDBTyp, $pNewInstance);
    $this->select = 'id, typ, nr, text ';
    $this->orderby = ' nr ';
  }

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

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

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

    return $tmp;
  }

  
  public function getSonderwuenscheByTyp($pTyp)
  {
    $typ = $this->dboperation->getString4Sql($pTyp);
    $sql = 'select ' . $this->select . ' from hlsonderw ';
    $sql .= "where typ = '" . $typ . "'";
    $sql .= ' order by ' . $this->orderby;
    $this->dboperation->clear();
    $this->dboperation->query($sql);

    return $this->getAllRows();
  }
}