Relating to a post I submitted a while back, along with creating a data connection on the fly I had to switch between two connections. That is, file based default connection and a dynamic connection based on user. Here is the scenario. Continue reading
As you know one would generate the cakephp table schema as:
$ cake schema generate
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;