CakePHP – Get Current URL in View

echo Router::url($this->here, true);


echo $this->here;


CakePHP – Sessions

print_r($this -> Session -> read());

$this -> Session -> write("variable", "value");
$this -> Session -> read("variable");

$user_email = $this -> data['User']['email'];
$user       = $this -> User -> find("email = '$user_email'");
$this -> Session -> write('User', $user['User']);

$this -> Session -> read("");

if ($this -> Session -> valid()){
	$this -> Session -> destroy();
	$this -> redirect('/');

Various PHP-related Resources

I found a few links which point to PHP-related resources, here we are…

Please note that these files are hosted in servers which located in Indonesia, so access from outside Indonesia may be a bit slower…

PHP E-books:



Code Igniter:



I’ve added links for non-Indonesian users…





PHP Security

CakePHP – Find, FindAll, Find(‘all’), Read

Use Model::read() when you have the ID, ie: you know the record you are referring to. Also read() will populate the Model::$data in a way suitable for Model::save() while find() will simply return the resultset array.

Use find() / findAll() / find(‘all’) to find records.

Both methods should fetch associated models given the correct Model::$recursive value.

Model::read is only a wrapper for Model::find


[CakePHP] Disable Model Queries Caching

Again a simple tip. CakePHP by default, in order to optimize performance, has a query caching system. This is a very cool feature but sometimes it may be self-defeating. For example when you do queries for Unit Testing.

In order to disable query caching, it’s enough to set the model cacheQueries variable to false. Setting it to true will re-enable queries caching.

You can disable it for the whole model “life-time” setting it during “design time”

class Project extends AppModel {
var $name = "Project";
var $customValidate = array("name");
var $cacheQueries = false;

or you can temporarily disable it by calling the $this->Model->cacheQueries=false (use your model instead of “Model”)


Configuring Dreamweaver 8 for Editing .thtml File

I needed Dreamweaver to recognize a new file extension called, “thtml” for CakePHP. Here is how I got Dreamweaver to recognize new code extensions and highlight them correctly:

  1. Edit your Extensions.txt file: C:\\Documents and Settings\\User\\Application Data\\Macromedia\\Dreamweaver 8\\Configuration
  2. Add in the new file extension into its type: HTM,HTML,HTA,HTC,XHTML,THTML:HTML Documents
  3. Now Dreamweaver recognizes the new file types but to get code highlighting you need to edit your MMDocumentTypes.xml file: C:\\Program Files\\Macromedia\\Dreamweaver 8\\Configuration\\DocumentTypes
  4. Add in the new file extension to HTML winfileextension.

Here is the full article by Adobe: Adobe: Changing and adding file extensions recognized by Dreamweaver