Posts Tagged ‘cakephp’

CakePHP: Convert a complex find condition from 1.1 to 1.3

Sunday, March 7th, 2010

First, findAll() no longer exists in 1.3, you need to use find(‘all’).
Then the conditions array structure is different, moving from a key/value pair array to an array with values only.

This is the query in 1.1:

 $conditions = array("OR" => array(
      'Item.expiration'       => 0,
      'Item.expiration >'     => "NOW()"
 $items = $this->Item->findAll($conditions);

Re-written for 1.3:

$conditions = array("OR" => array(
      'Item.expiration = 0',
      'Item.expiration > NOW()' // single string
 $params = array(
   'conditions'    => $conditions
 $items = $this->Item->find('all', $params);


IE bug: text disappearing randomly behind a picture

Wednesday, January 20th, 2010

Even though the text had a high z-index, it would disappear after few seconds behind the picture it’s supposed to be on, or when you switch to another Windows application then come back on the browser.

This erratic behavior turned out to be when IE doesn’t have a Doctype declared.

CakePHP doesn’t define any Doctype by default, so you need to edit your default layout and include it.

In CakePHP 1.1: edit app/views/layout/default.hthml

In CakePHP 1.1: edit app/views/layout/default.ctp

and add:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

… at the very top, before the html tag.

This happens not even on an old IE6, but on IE8 itself.