<?php
 namespace Entity; class Department extends \App\Entity\GeneralAbstract { protected $saveInsideTransaction = false; const cacheTtl=604800; protected function setTableName(): void { global $DBTDepartments; $this->tableName=$DBTDepartments; } static public function current() { return self::select(CURRENT_ID_DEPT); } protected function getAttribute($var) { switch ($var) { case 'addUser': { return User::select($this->fields['idAddUser'], $this->selectForUpdate); } case 'updateUser': { return User::select($this->fields['idUpdateUser'], $this->selectForUpdate); } default: { return parent::getAttribute($var); } } } protected function setAttribute($var, $value) { if ($this->operation!='insert' and $this->operation!='update') { throw new \Exception('You can call '.__METHOD__.' only for insert/update operations.'); } switch ($var) { case 'name': case 'code': { $this->fields[$var]=$value; break; } default: { throw new \Exception("The field '$var' is not valid for the `".__CLASS__."` entity."); } } } } 