Bookcafe

Sunday, August 1, 2010

CakePhp : Three Basic Functions

From all my readings, I found out there are three basic codes for functions in CakePhp as to are to add, to edit and to delete data. The codes are all similar in all the books that I have read. All these functions are put into
models_controller.php files.

//To save/add data

function add()
{ if (!empty($this->data)) { $this->Modelname->create(); if(!!$this->Modelname->save($this->data)) { $this->Session->setFlash('Your data is Saved!', true); $this->redirect(array('action'=>'index')); } } }