Web Development
Having worked with CakePHP on several projects, I have definitely found may quirks in how CakPHP works. There are instances that you would have expected things to work but doesn't.

One of CakePHP most wanted is CakePHP's Has and Belongs to Many (HABTM) relationships. Here is the easiest way to add HABTM relationship to a Model.


$type = $this->Type->find('first', array('conditions' => array('name' => 'Developer')));
$this->User->set(
    array(
        'id' => 1,
        'name' => 'Thorpe Obazee'
        'Type' => $type
    )
);


This without a doubt works! Our user will have a HABTM relationship with our Developer Type. Looking at this example, how would you add the User 2 HABTM relationships?

Well let's see.


$types = $this->Type->find('first', array('conditions' => array('name' => 'Developer'), 'limit' => 2));
$this->User->set(
    array(
        'id' => 1,
        'name' => 'Thorpe Obazee'
        'Type' => array($types)
    )
);


Would you have expected this to work? Well, it doesn't. Adding multiple HABTM relationships in CakePHP is quite different than adding a single one. Here's the way to add multiple HABTM relationships.


$types = $this->Type->find('first', array('conditions' => array('name' => 'Developer'), 'limit' => 2));
$type_ids = array();

foreach ($types as $type) {
    $type_ids[] = $type['Type']['id'];
}

$this->User->set(
    array(
        'id' => 1,
        'name' => 'Thorpe Obazee'
        'Type' => $type_ids
    )
);


Voila! This works! I have come to love CakePHP like any other framework I've used. I don't know if this is intentional on the part of the developers but I don't find it very intuitive.