Пример #1
0
 /**
  * Creates and returns a model object of the requested class.
  * 
  * @param string $name The model name having the form: ModuleName.ModelName. 
  * @param boolean $createTable If TRUE the table associated to the model is created if not exists. FALSE by default. 
  * 
  * @return object A connected model.
  */
 public static function model($name, $createTable = false)
 {
     if (strpos($name, '.') === false) {
         throw new \Exception("Malformed model name: {$name}. Form: Module.ModelName.");
     }
     $rt = explode('.', $name);
     $modelName = "\\App\\Modules\\{$rt[0]}\\Models\\{$rt[1]}";
     $model = new $modelName();
     $dbConn = self::dbConn();
     $model->dbConn($dbConn);
     if ($createTable) {
         $mde = new \Lib\Data\MetadataEngine();
         $mde->model($model);
         $mde->createTable();
     }
     return $model;
 }
 /**
  *
  */
 public function createTable()
 {
     $metadataEngine = new \Lib\Data\MetadataEngine();
     $metadataEngine->model($this);
     $metadataEngine->createTable();
 }