<?php
namespace Entity; class TaskCategory extends \App\Entity\GeneralAbstract { protected $saveInsideTransaction = true; protected $addAndUpdateDateTimeFormat = 'timestamp'; protected function setTableName(): void { global $DBTTasksCategories; $this->tableName = $DBTTasksCategories; } protected function getAttribute($var) { switch ($var) { case 'name': { if (!array_key_exists('name', $this->fields)) { $this->fields['name'] = $this->fields['category']; } return $this->fields['name']; } 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 use __set magic method only with insert/update operation in `'.__CLASS__.'` class.'); } switch ($var) { case 'category': case 'description': $this->fields[$var]=$value; break; default: throw new \Exception("The field '$var' is not valid for the `".__CLASS__."` entity."); } } }