We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Multiple Date columns in a table problem

Hello,

I have stumbled upon a strange error:

I have a table in MySQL:

CREATE TABLE event ( id int(11) NOT NULL AUTO_INCREMENT, start_date date NOT NULL, end_date date DEFAULT NULL, PRIMARY KEY (id), );

My model looks like that: class Event extends \Phalcon\Mvc\Model {

public $id;
public $start_date;
public $end_date;

public function initialize() {
    $this->setSchema("MyDatabase");
    $this->setSource("event");
}

public function getSource() {
    return 'event';
}

public static function find($parameters = null) {
    return parent::find($parameters);
}

public static function findFirst($parameters = null) {
    return parent::findFirst($parameters);
}

}

When I do:

$event = new Event; $event->start_date = '2018-01-01'; $event->end_date = '2018-02-02';

$event->save();

Nothing is happening - no data inserted into the database I have implemented a listened on the database

$dbListener = new MyDbListener(); $eventsManager->attach('db', $dbListener);

Not even a qury is executed.

When I remove one of the date columns all works fine!

It looks like phalcon does not like two columns with date type in one table.

I would appreciate someone gave me some advice where the problem might be.

I ma trying to avoid to write sql strng (I know it can be done this way) I want to use proper way by using the phalcon models.

Please help!

Regards Rafal