Posted By

stolkchris on 09/19/10


Tagged

data cakephp model dynamic retrieval


Versions (?)

CakePHP - Dynamic Model


 / Published in: PHP
 

A small snippet on how to create a dynamic model in CakePHP (useful for global functions that need a model to function. IE functions defined in the AppController

  1. <?php
  2.  
  3. // THE DYNAMIC MODEL
  4. App::Import('Model', $model);
  5. $this->DynamicModel = new $model;
  6.  
  7. // USAGE EXAMPLE
  8.  
  9. function getModelColumns($model){
  10. App::Import('Model', $model);
  11. $this->DynamicModel = new $model;
  12. print_r($this->DynamicModel->getColumnTypes());exit();
  13. }
  14.  
  15. ?>

Report this snippet  

You need to login to post a comment.