12345678910111213141516171819202122232425262728293031323334353637 |
- <?php
- class BaseDBO
- {
- public function GetId()
- {
- return $this->id;
- }
- public function __get($name)
- {
- if ($name == 'id')
- return $this->id;
- }
- public function Save()
- {
- global $entityManager;
- $entityManager->persist($this);
- $entityManager->flush();
- }
- public static function Find($id)
- {
- global $entityManager;
- return $entityManager->find(get_called_class(), $id);
- }
- public static function Delete($id)
- {
- global $entityManager;
- $user = $entityManager->getReference(get_called_class(), $id);
- $entityManager->remove($user);
- $entityManager->flush();
- echo "Элемент удален: $id";
- }
- }
|