As you know one would generate the cakephp table schema as: $ cake schema generate
Category: CakePHP
CakePHP Create Datasource on the fly
Want to switch between different databases in a CakePHP action? Do you want to use different database for different clients or sites? Don’t worry the solution more simpler than you thought it to be. Following this link and few other similar…
Contain and selected fields of model with User _attachAttributes
I am in a Task model. I build following options to load the Task and associated User model data.
CakePHP deleteButton when SoftDelete Behavior in Effect
Here is a piece of code placed as a helper function. Useful to create a delete button/link while having SoftDeleteBehavior enabled for a Model. For example, placed in data management page (view page such as admin_index.ctp or index.ctp) of your…
Form Helper: custom decimal field format in number field
I have a database table field defined as decimal(10,5). I want to use it for various purposes so I don’t want to change the datatype. In most of the forms however I want to keep this field showing none or very…
ACL: Checking Permissions in Views, Fixed
Following the post (http://goo.gl/PLeNJR) for ACL: Checking Permissions in Views like some others I faced a “undefined index User…” and some other PHP warnings when trying to implement this example. After doing some testing following the working code I came…
Containable with mixed arguments, the CakePHP Beauty!
Here’s an example of CakePHP Containable behaviour. Although, it was not a very complex find call but the beauty of the containable is this that you can fetch records using “tricky ways” which normally may not be possible with straight…
How to paginate a different model with options in CakePHP
Assume you are on a LogsController which has Log as the default model and wanted to paginate another model LogColumn. Here’s How it goes:
How to get model name from controller in cakephp
Suppose we have $controller as an object for our controller class. We can do the following to get the model class: [code]$modelName = $controller->modelClass;[/code]
An example of CakePHP complex find conditions
Setting complex ‘find’ conditions in CakePHP can be tricky. I picked an example of Cakephp complex find conditions from one of my CakePHP projects. I wanted to list all auctions which are “not closed” and whose’ end date/time is greater…