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

Oracle inserting dates

Hi

I've been working on an app that has to manage data on an Oracle and MySQL DB.

So far I've been able to sort most issues, but I'm a little stumped with dates... If I try to insert with a value TO_DATE(xxxx) Oracle interprets it as a String, not a Date.

How can I manage this in phalcon?

Thanks

Ronald Melo

Could you please post the code you're using to do the insertion?

edited Jan '16

I'm with the same problem. I used a TRAIT to enter the date of inclusion and registry modification. The correct way is to insert the SYSDATE for ORM put the current date. But how?

<?php
trait beforeCreate {

  public function beforeCreate() {
    $this->createIn = 'SYSDATE';
    $this->skipAttributesOnCreate(
            array('updateIn')
    );
  }

I tried using date('Ymd') but I get the ORA-01861 error.



2.5k
Accepted
answer
edited Jan '16

I could !!! Searching further in Forum saw this recommendation:

\Phalcon\Db\RawValue

My implementation:

$this->updateIn = new \Phalcon\Db\RawValue('SYSDATE');