zen of coding

If you use UUID’s…

Be extra careful to make sure that, according to convention, your ‘id’ column (or primary key) is: char(36) and never varchar(36) CakePHP will work with both definitions, however you will be sacrificing about 50% of the performance of your DB (MySQL in particular). This will be most evident in more[…]

Read More »

find(‘first’)… gotcha

Just a simple tip… Here’s a typical find() example: $this->Post->find(’first’, array(’condition’ => array(’id’ => 5))); Why does it return me the post with ID = 1, rather than ID = 5? Of course, a careful reader spotted the spelling issue in the key: ‘condition’ instead of ‘conditions’. Moral of the[…]

Read More »

Installing membase/memcached

These are instructions for getting membase/memcached installed in your local environment. (I was installing on windows so your setup might be a little different, but general approach is mostly the same). 1. Download the membase server for your OS (community edition is the one you are after): http://www.couchbase.com/downloads Once downloaded,[…]

Read More »

Speed up your pagination with a simple hack…

Before I go into the example in this little post, let me just say that this situation won’t be applicable to everyone… But let’s consider the following: We have a table with tens of thousands of records, that need to be paginated. As you know, cake will execute two queries;[…]

Read More »

Dealing with static pages v2 (or… 3?)

Over the years of cake development we’ve seen a number of ways to get rid of the the /pages/ path in the URL for static pages. By default if you create an “about us” page, such as in app/views/pages/about.ctp, the resulting URL would be: www.example.com/pages/about I’m sure you’ve seen a[…]

Read More »

Be mindful of the redirect(s)

Just a couple of tidbits about CakePHP redirects, prefix routing and Auth. 1. Auth mysteriously redirects your logged in user into the abyss… After you’ve checked all your setting in beforeFilter()’s of App Controller and relevant Controllers, it still seems like a completely bizarre situation where all of a sudden[…]

Read More »

Speed things up with a custom-baked JSON view

Yet another gem of brilliance from Mr. jrbasso. In a couple of my previous posts regarding CakePHP and JQuery, I’ve shown some basic strategies on setting up the communication between the client and the server. This post, as one can guess from the title, is going to be more about[…]

Read More »

Two ways to debug your AJAX queries

Every once in a while you might have a need to trigger an AJAX action in the controller, which should return some results from the server… When everything works, well it is certainly all fine and dandy, but if things go haywire, first thing to check out is the response[…]

Read More »

Make your CakePHP app ridiculously faster with “view caching”

Big or small, once your app goes to production you’d better start thinking about utilizing view caching ;) Granted, view caching in a dynamic application can be tricky or impossible(?)… but with proper usage wherever and whenever needed, it can make your app go off the charts in terms of[…]

Read More »

Checking for SSL and then some…

A simple way to check and enforce SSL can be done by using the RequestHandler component. Here’s an example: private function checkHttps() {   if(!$this->RequestHandler->isSSL()) {     return $this->redirect(’https://’ . env(’SERVER_NAME’) . $this->here);   } } Simple enough, right? Yet there is a little caveat, which causes a problem[…]

Read More »
%d bloggers like this: