This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
#/app/controller/BooksController.php | |
class BooksController extends AppController { | |
public function index() | |
{ | |
$this->Book->recursive = 1; | |
$books = $this->Book->find('all'); | |
$this->set('authors', $authors); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
# /app/Model/Contact.php | |
class Contact extends AppModel { | |
public $displayField = 'fullname'; | |
public $virtualFields = array( | |
'fullname' => 'CONCAT(Contact.name, " ", Contact.surname)', | |
'withCompany' => 'CONCAT(Contact.name, " ", Contact.surname, " - ", Contact.company', | |
'bySurname' => 'CONCAT(Contact.surname, " ", Contact.name)', | |
'createdIta' => 'DATE_FORMAT(Contact.created,"%d/%m/%Y")' | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
# /app/Model/Contact.php | |
class Contact extends AppModel { | |
public $displayField = 'fullname'; | |
public $virtualFields = array( | |
'fullname' => 'CONCAT(Contact.name, " ", Contact.surname)', | |
'withCompany' => 'CONCAT(Contact.name, " ", Contact.surname, " - ", Contact.company', | |
'bySurname' => 'CONCAT(Contact.surname, " ", Contact.name)', | |
); | |
public function getUserInfos($id) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
# /app/Model/Contact.php | |
class Contact extends AppModel { | |
public $displayField = 'fullname'; | |
public $virtualFields = array( | |
'fullname' => 'CONCAT(Contact.name, " ", Contact.surname)', | |
'withCompany' => 'CONCAT(Contact.name, " ", Contact.surname, " - ", Contact.company', | |
'bySurname' => 'CONCAT(Contact.surname, " ", Contact.name)', | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
# /app/Model/Contact.php | |
class Contact extends AppModel { | |
public $displayField = 'fullname'; | |
public $virtualFields = array( | |
'fullname' => 'CONCAT(Contact.name, " ", Contact.surname)' | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE `contacts` ( | |
`id` int(11) unsigned NOT NULL AUTO_INCREMENT, | |
`name` varchar(150) DEFAULT NULL, | |
`surname` varchar(150) DEFAULT NULL, | |
`company` varchar(200) DEFAULT NULL, | |
`created` datetime DEFAULT NULL, | |
`modified` datetime DEFAULT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
# app/Model/AppModel.php | |
class AppModel extends Model { | |
public function save($data = null, $validate = true, $fieldList = array()) { | |
$this->set($data); | |
// se esiste il campo modified verrà rimosso dall'array | |
if (isset($this->data[$this->alias]['modified'])) { | |
unset($this->data[$this->alias]['modified']); | |
} | |
return parent::save($this->data, $validate, $fieldList); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE `contacts` ( | |
`id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, | |
`name` VARCHAR(150) NOT NULL, | |
`surname` VARCHAR(150) DEFAULT NULL, | |
`company` VARCHAR(200) DEFAULT NULL, | |
`created` DATETIME DEFAULT NULL, | |
`modified` DATETIME DEFAULT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=INNODB DEFAULT CHARSET=utf8; |