fork download
  1. <?php
  2.  
  3. interface IModel{
  4. public function getFields();
  5. public function save();
  6. }
  7.  
  8. abstract class EntityModel{
  9. // здесь будут все необходимые методы для работы с моделью
  10. }
  11.  
  12. class UserModel extends EntityModel implements IModel{
  13. // так как вы имплементируете интерфейс,
  14. // то вы никогда не забудите реализовать все необходимые вам методы модели
  15. public function getFields(){
  16. return array("id", "login");
  17. }
  18.  
  19. public function save(){
  20. echo "save good \n";
  21. return true;
  22. }
  23. }
  24.  
  25. $user = new UserModel();
  26. print_r($user->getFields());
  27. $user->save();
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
Array
(
    [0] => id
    [1] => login
)
save good