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.
I am in a Task model.
I build following options to load the Task and associated User model data. Continue reading
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 application. Continue reading
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 limited number of decimal points. Continue reading
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 up with. I think it may help some one there. Continue reading
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 associations find calls. Continue reading
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: Continue reading
Suppose we have $controller as an object for our controller class. We can do the following to get the model class:
$modelName = $controller->modelClass;
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 that the current date/time. I can use the following statement. Continue reading