Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //require_once dirname(dirname(__FILE__)) . "/config/config.php";
- class model extends Loader
- {
- private $models;
- function __construct()
- {
- parent::__construct();
- }
- public function load_model($model_name,$data = array())
- {
- if($model_name != 'model')
- {
- if(file_exists(dirname(__FILE__) . "/" . $model_name . ".php"))
- {
- if(in_array($model_name, get_declared_classes()))
- $this->logger->output('Class ' . $model_name . ' is already declared.','error');
- else {
- require_once(dirname(__FILE__) . "/" . $model_name . ".php");
- $this->models[$model_name] = new $model_name($data);
- return true;
- }
- }
- else {
- $this->logger->output('File ' . $model_name . '.php dose not exists.','error');
- return false;
- }
- }
- else {
- $this->logger->output('Model name can\'t be "model"','error');
- return false;
- }
- }
- public function get_model($model_name)
- {
- if(array_key_exists($model_name, $this->models))
- return $this->models[$model_name];
- else {
- $this->logger->output('Model name could not be found. Model ' . $model_name,'error');
- return false;
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment