CakePHP – Get Current URL in View


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

or

echo $this->here;

Advertisements

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("User.email");

if ($this -> Session -> valid()){
	$this -> Session -> destroy();
	$this -> redirect('/');
}
Source:
http://justkez.com/understanding-cakephp-sessions/

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:

Joomla:

CakePHP:

Code Igniter:

Software:

Update:

I’ve added links for non-Indonesian users…

PHP

Joomla

PHP-Oracle

PEAR

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

Source:

http://n2.nabble.com/Difference-between-read-and-find-td726658.html

[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”

<?php
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”)

Source:

http://edivad.wordpress.com/2008/04/15/cakephp-disable-model-queries-caching/

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

Source:

http://marcgrabanski.com/article/edit-cakephps-thtml-with-dreamweaver