zen of coding

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: function afterFind($results, $primary=false) {       if($primary == true) {      […]

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 »

Dealing with calculated fields in CakePHP's find()

Let’s say we’ve got some calculated field in our find() method, something like SUM() or COUNT() or maybe AVG(). For the sake of example let’s do something simplistic, like: pr($this->Company->find(’all’, array(’fields’=>array(’Company.id’,’Company.name’, ‘COUNT(id) AS total_count’),                                […]

Read More »
%d bloggers like this: