Tagged with CakePHP

Prevent Cron Task Overlap in CakePHP

If you have a task that runs every 5 minutes, and it takes more than 5 minutes to run then the next task will start causing even more server load. This effect may stack up and eventually cause your server to come to a grinding halt. For this reason it is very important that your scheduled tasks do not overlap.

Multiple Primary Keys in CakePHP

If you have ever tried to deal with multiple primary keys in cakePHP then you have probably hit a brick wall at some stage. Although you still need to add a single id field, this example will allow you to save your data without needing to know the id.

Importing Data from CSV into CakePHP

This is a quick little method that lets you get some data from a CSV into a table. It should work with very large CSV files as it only has to read one row at a time.

Auto-Set the ID beforeSave in CakePHP

In this quick snippet of code I will be setting the ID of a model based on other fields given. We want to save a note about each Post that is different for every Client, however we do not want to have to get the ID every time we save the data.

Working with HABTM Form Data in CakePHP

I would like to document several speedy ways I have of working with HABTM data.

View a Random Record in CakePHP

This is a simple action to display a random record. Possibly useful for sites wanting to keep people clicking on something.

Update Multiple Records using Multi-Actions in CakePHP

In this CakePHP tutorial I will explain how to update multiple records in a single action. This will typically be used as an extension to the index views in your application, allowing a user to select which rows they would like to update, and then performing an action.

Simple Auth with Users HABTM Groups in CakePHP

In almost every project I need to setup some sort of login, and usually it requires group access to certain data depending on different criteria. For example I may have groups Admin+Member and I want Members to only be able to see other Users Profiles if the other Profile is active.

Search Forms in CakePHP

In this CakePHP tutorial I would like to show you how I handle search forms, while preserving pagination. The basic principal is to read the posted variables, and redirect the user to a page with the appropriate filters in the URL.

Page Breadcrumb Links in CakePHP

I wanted to make a quick and easy breadcrumb that worked with a simple array. The breadcrumb is an array containing multiple links from html_helper::link().

Multiple Flash Messages with Style in CakePHP

In this CakePHP tutorial I will explain how to output multiple flash messages. This forms a message stack that can be used to inform the user that multiple events have taken place.

Merge your Add and Edit actions into a Single Form in CakePHP

This CakePHP example will show you how to merge your Add and Edit forms into a Single Form action. This may be of benefit if you have a form with complex controller logic that you don't want to duplicate.

Fun with Tree Behaviour in CakePHP

I had a play with the Tree Behaviour in CakePHP and was very impressed at what you could create with such ease.

Attach Comments to Any Model in CakePHP

This method of linking models allows you to have a single table of data, say Comment, that is related to any one of a number of other Models (eg: Post, Event).

Admin Editable Settings and Theme in CakePHP

Usually the client will request for me to give them a way to edit simple settings in their application. I decided to read all the variables from the database in the beforeFilter to make them available in any controller.

Fully Qualified Domain Name and Base Path

This simple snippet will provide you with a HTTP or HTTPS Fully Qualified Domain Name URL and Base Path to your CakePHP installation. I use it for the HTML base tag.