Heres what im trying to do
Ive got table that holds many different types of data for items. the model name for this is ‘Object’
for example :
row 1 : item_type = event
row 2 : item_type = news
row 3 : item_type = booking
i want to write a controller ‘event_controller’ and use the ‘Object’ model with it and only deal with item_types of event. and another controller for news (news_controller) and use the same model.
how do i do this on cakephp.
Im coming into cake from codeigniter and in CI we can load any model we want into any controller can i do something similar with cake?
I would like to suggest you to not to
$usesstatement. Instead of that you can use relations of the models like$this->Model->M0del1->....->someFunc();if the relation exists.If the relation between the models dos’t exist then simply use
$this->loadModel('ModelName');in the specific function where-ever you need it.If you use var
$uses = array('Object');it becomes global to the controller and it will load that model for all the actions of the controller despite of whether you require it or not. This will affect your performance.If you use
$this-LoadModel('ModelName');in a particular function it will only load in that function not in all the actions.