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.

41 lines
888 B

  1. <?php
  2. /**
  3. * @package uForum2
  4. * @file inc/askModel.class.php
  5. * @copyright 2007-2015 (c) PioDer
  6. * @link http://www.pioder.pl/
  7. * @license see LICENSE.txt
  8. **/
  9. require_once('./inc/model.class.php');
  10. abstract class AskModel
  11. {
  12. protected $models = array();
  13. function loadModel($model)
  14. {
  15. if (file_exists('./inc/models/'.$model.'.class.php') && !array_key_exists($model, $this->models)) //singleton
  16. {
  17. require_once('./inc/models/'.$model.'.class.php');
  18. $this->models[$model] = new $model($this->db);
  19. }
  20. else
  21. {
  22. throw new Exception('Could not load selected model: '.$model);
  23. }
  24. }
  25. function getModel($model)
  26. {
  27. if (array_key_exists($model, $this->models))
  28. return $this->models[$model];
  29. else
  30. throw new Exception('Could not get selected model: '.$model);
  31. }
  32. function putExistingModel($model, &$model_ptr)
  33. {
  34. $this->models[$model] = $model_ptr;
  35. }
  36. }
  37. ?>