Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save aaoliveira/905cf9abb05a672e5150 to your computer and use it in GitHub Desktop.
Save aaoliveira/905cf9abb05a672e5150 to your computer and use it in GitHub Desktop.
<?PHP
class Minhamodel extends AppModel{
//Primeira opção, caso nunca mude o "alias" da model
public $virtualFields = array(
'data_formatada'=>"DATE_FORMAT(Minhamodel.data,'%d/%m/%Y')",
);
//Alternativa caso mude o "alias" da model, melhor opção
public function __construct($id=false,$table=null,$ds=null){
parent::__construct($id,$table,$ds);
$this->virtualFields['data_formatada'] = "DATE_FORMAT({$this->alias}.data,''%d/%m/%Y)";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment