Return to Snippet

Revision: 32154
at September 19, 2010 20:46 by stolkchris


Initial Code
<?php

// THE DYNAMIC MODEL
App::Import('Model', $model);
$this->DynamicModel = new $model;

// USAGE EXAMPLE

function getModelColumns($model){
    App::Import('Model', $model);
    $this->DynamicModel = new $model;
    print_r($this->DynamicModel->getColumnTypes());exit();
}

?>

Initial URL

                                

Initial Description
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

Initial Title
CakePHP - Dynamic Model

Initial Tags
data, cakephp

Initial Language
PHP