PostIT

while scratching my head…

CakePHP – Create Controller Action without View September 12, 2008

Filed under: CakePHP, PHP — Remo @ 5:56 am
Tags: ,

just add:

$this->autoRender = false;

 

CakePHP – Sessions September 10, 2008

Filed under: CakePHP, PHP — Remo @ 12:05 pm
Tags: ,
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/

 

CakePHP – Find, FindAll, Find(‘all’), Read September 10, 2008

Filed under: CakePHP, PHP — Remo @ 10:37 am
Tags: , , ,

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 September 6, 2008

Filed under: CakePHP, PHP — Remo @ 11:50 pm
Tags: , ,

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 September 6, 2008

Filed under: CakePHP, Dreamweaver, PHP, Uncategorized — Remo @ 1:47 pm
Tags: , , ,

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