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

class DBWorkWebTemplates extends DBWorkGenerated
{
  public function __construct($pDBTyp = 1, $pNewInstance = false)
  {
    parent::__construct($pDBTyp, $pNewInstance);
    $this->select = 'id, description';
    $this->_dataModulFields = array('description', 'id');
  }

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

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

  public function getTemplateArray()
  {
    $all = $this->getAll();
    $templateArray = array();
    foreach ($all as $template) {
      $templateArray[$template->id] = $template->description;
    }

    return $templateArray;
  }

  public function getTemplateById($id)
  {
    $qb = $this->getSelectQueryBuilder();
    $qb->select($this->select)
       ->from($this->getTableName())
       ->where('id = :id:')
       ->paramInt('id', $id);
    $this->dboperation->clear();
    $this->dboperation->query($qb->getSQL());

    return $this->getFirstRow();
  }
}