A new, object-oriented, better vesion of μForum
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
702 B

  1. <?php
  2. abstract class AskModel
  3. {
  4. protected $models = array();
  5. function loadModel($model)
  6. {
  7. if (file_exists('./inc/models/'.$model.'.class.php') && !array_key_exists($model, $this->models)) //realizowany singleton
  8. {
  9. require_once('./inc/models/'.$model.'.class.php');
  10. $this->models[$model] = new $model($this->db);
  11. }
  12. else
  13. {
  14. throw new Exception('Could not load selected model: '.$model);
  15. }
  16. }
  17. function getModel($model)
  18. {
  19. if (array_key_exists($model, $this->models))
  20. return $this->models[$model];
  21. else
  22. throw new Exception('Could not get selected model: '.$model);
  23. }
  24. function putExistingModel($model, &$model_ptr)
  25. {
  26. $this->models[$model] = $model_ptr;
  27. }
  28. }
  29. ?>