In my html code is being generated date in the following format "yyyy-mm-dd", I need to save it in the format 'DD / MM / YYYY'. This is because my database is Oracle. How could I change it?
|
Apr '16 |
5 |
1243 |
0 |
Add in beforeSave:
// if it's already DateTime object:
$this->date = $this->date->format('d/m/Y');
//if not create one:
$this->date = (new DateTime($this->date))->format('d/m/Y');
How do I set my function for variables? $CONT_FECNACI; $CONT_FECINSC
this is my model <?php
class SpmContacto extends \Phalcon\Mvc\Model
{
public $CONT_CODIGO;
public $CONT_CEDULA;
public $CONT_RUCIDE;
public $CONT_NOMBRE;
public $CON_ESTADO;
public $CONT_TELEFO;
public $CONT_DIRECC;
public $CONT_AREA;
public $CONT_CARGO;
public $CONT_TIPOXX;
public $CONT_EMAIL;
public $CONT_USUARIO;
public $CONT_CLAVE;
public $CONT_CLAVEE;
public $CONT_FECNACI;
public $CONT_FECINSC;
public $CONT_TIPOCODIGO;
/**
* Initialize method for model.
*/
public function initialize()
{
$this->setSchema("SPOLS");
$this->hasMany('CONT_CODIGO', 'SPMREFERENCIA', 'CONT_CODIGO', array('alias' => 'SPMREFERENCIA'));
$this->hasMany('CONT_CODIGO', 'SPTDETALLE', 'CONT_CODIGO', array('alias' => 'SPTDETALLE'));
$this->hasMany('CONT_CODIGO', 'SPTENCABEZADO', 'CONT_CODIGO', array('alias' => 'SPTENCABEZADO'));
}
public function getSource()
{
return 'SPM_CONTACTO';
}
public static function find($parameters = null)
{
return parent::find($parameters);
}
public static function findFirst($parameters = null)
{
return parent::findFirst($parameters);
}
}
Yes it's reason good enough to not learn FRAMEWORK. For first learn PLAIN PHP and object and OOP. For isntance:
$this->$CONT_FECNACI // there is no $CONT_FECNACI variable in beforeSave() function
$this->$CONT_FECINSC // there is no $CONT_FECINSC variable in beforeSave() function
$CONT_FECNACI->date->format('dd/mm/YYYY'); // there is no $CONT_FECINSC variable in beforeSave() function, also are you sure that $CONT_FECNACI have property with name date ?
$CONT_FECINSC->date->format('dd/mm/YYYY'); // there is no $CONT_FECINSC variable in beforeSave() function, also are you sure that $CONT_FECNACI have property with name date ?
Those problems are not framework related. You just wrote wrong code and you could wrote it in any framework. First learn plain php, objects, classes etc - then start with framework.
Thank you very much for your help and have a different result continuare consulting
public function beforeSave()
{
$CONT_FECNACI = (new DateTime($CONT_FECNACI))->format('d/m/Y');
$CONT_FECINSC = (new DateTime($CONT_FECNACI))->format('d/m/Y');
}
DateTime::__construct(): Failed to parse time string (25/04/2016) at position 0 (2): Unexpected character