zen of coding

Editing multiple records with saveAll()

Another interesting topic was brought up on IRC channel today… (By the way if you don’t know about the awesome CakePHP IRC channel, you really should visit, it is a great place to get help and learn a thing or two… irc://irc.freenode.net/cakephp) Anyways, moving on… How do we edit multiple[…]

Read More »

You lucky Mac users…

I came across this really awesome looking product today, called ModelBaker. It is a nice GUI environment (and then some), which allows one to easily and intuitively build web apps on top of the CakePHP platform. I only had a chance to look at the screen casts so far, but[…]

Read More »

How to validate HABTM data…

Update: Since writing of this article the ‘rule’ => ‘multiple’ has been implemented in cake core. It is much more convenient to use for HABTM validation. You may consider this post deprecated and only to be used for historical purposes or if you are working with an older code-base. So[…]

Read More »

Demystifying Auth features in CakePHP 1.2

This is actually a quick follow-up to the tutorial I’ve posed recently, which had a few simple, but not very obvious Auth component techniques. I’d like to cover them in more detail here… Let’s take a look at the app_controller.php again: [cc lang=”php”] class AppController extends Controller { var $components[…]

Read More »

Introduction to CakePHP features (build an app in less than 15 minutes)

I would like to showcase the awesome power of CakePHP by providing an introductory tutorial, which is going to cover some basics as well as slightly more advanced features such as the Auth (user authorization) component. The goal of this tutorial is to setup a working application, which is going[…]

Read More »

CakePHP + MySQL + Tinyint(1) = Confusion

Just a quick note to point out that CakePHP fakes a BOOLEAN field in MySQL by using tinyint(1). MySQL doesn’t have a native support for BOOLEAN. Therefore if you attempt to save some value other than 0 or 1, CakePHP will not allow you to do that (instead it will[…]

Read More »

Sharing CakePHP session with another app

This question pops up once in a while: “How do I share session data with a third-party application?” Thankfully the answer is pretty simple, just make sure that the session (cookie) name is the same for both apps. In CakePHP it’s set in the core.php… Configure::write(‘Session.cookie’, ‘CAKEPHP’);

Read More »

PHP5 and tiny foreach() improvement

While this issue is certainly not specific to CakePHP, I felt it was worthwhile to point out since we are often dealing with data arrays and foreach() loops to modify that data. Consider the following example: [cc lang=”php”] function afterFind($results, $primary=false) { if($primary == true) { foreach($results as $key =>[…]

Read More »

A few words about media views (sending binary files to the user)

Media views is one really nice feature of CakePHP which doesn’t get much attention, so I figured to briefly cover it here. Actually the manual lists pretty much all you need to know about media views, but there are a couple of things that I’d like to point out. First,[…]

Read More »
%d bloggers like this: