More times then none when working with a database, you need a general purpose method for grabbing fields from a row that matches an id. Cake has built in magic methods based on the table column that do just that, for example findById() or findBySlug(), but sometimes it grabs associated data that you do not want. Below is a basic method that you can place in your AppModel to grab a row based on its id, with optional parameters for restricting what fields to grab or what associations to contain. Continue reading...
Compression
Compression is a light weight class that will load a CSS stylesheet, bind and translate given variables, compress and remove white space and cache the output for future use.
Entries for Data
About a week ago I talked about automatically sanitizing your data before its saved. Now I want to talk about automatically stripping HTML from your data before its saved, which is good practice. Personally, I hate saving any type of HTML to a database, thats why I prefer a BB code type system for this website. Continue reading...
So if you are like me and hate having to sanitize or clean your data manually within each action, and was hoping there was an easier way, there is. Simple combine the magic of the Models beforeSave() and the powerful strength of Sanitize::clean(). Continue reading...
When I first started using CakePHP, I couldn't find a way to pre-populate a form with data. Why would I need this you ask? Well its simple, it would be used to edit something already existent. So what I need to do is grab the data from the database, and then populate the form. Took me a few hours to figure out how to do it, the guide really didn't explain how it should be done (or I just overlooked it). To have the data populate, all you need to do is to set $this->data to the database result. Continue reading...
Popular Entries
Topics
- CakePHP (65)
- Code (19)
- Entertainment (2)
- Gaming (4)
- HTML & CSS (1)
- Javascript (6)
- jQuery (7)
- MySQL (1)
- Other (11)
- Personal (15)
- PHP (25)
- Plugins (5)
- Programming (9)
- Resources (13)
- Reviews (1)
- Tutorials (46)