Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to create a CakePHP model that doesn't refer to a table from the database?

I'm developing an API for C2DM to send push messages to Android devices. I have the API in PHP5 and I want to tranform it to CakePHP 2.0.

How can I create a model in CakePHP that doesn't refer to a table in the database? Is it possible to create such a model and a controller to manage it?

Or is there any existing code to do Cloud to Device Messaging (C2DM) in CakePHP?

Thanks in advance.

like image 777
Houcine Avatar asked Nov 23 '11 15:11

Houcine


People also ask

What is CakePHP model?

Usually, model classes represent data and are used in CakePHP applications for data access. They generally represent a database table but can be used to access anything that manipulates data such as files, external web services, or iCal events. A model can be associated with other models.

What are models in php?

From a PHP view, models are classes extending the AppModel class. The AppModel class is originally defined in the cake/ directory, but should you want to create your own, place it in app/app_model. php. It should contain methods that are shared between two or more models.


2 Answers

You can set $useTable to false in that particular tableless model, see the cookbook for further details.

like image 175
mensch Avatar answered Oct 06 '22 13:10

mensch


cakephp models have an attribute called $useTable which you can set to false.

like image 3
Julien Avatar answered Oct 06 '22 13:10

Julien