条令2错误ORA-01843:无效月份


Doctrine 2 error ORA-01843: not a valid month

我使用的是条令2Yii以及Oracle

我有一个DateTime字段

    /**
     * @var 'DateTime
     *
     * @ORM'Column(name="CREATE_DATE", type="datetime", nullable=true)
     */
    private $createDate;

我用这个代码把人插入表格

        $date = new 'DateTime("now");
        $person = new Person();
        $person->setCreateDate($date);
        $person->setLastName('name');
        $entityManager->persist($person);
        $entityManager->flush();

但是它返回这个错误:

An exception occurred while executing 'INSERT INTO PERSON (PERSON_ID, CREATE_DATE, LAST_NAME) VALUES (?, ?, ?)' with params [27, "2014-10-29 09:23:38", "name"]:
ORA-01843: not a valid month 

请帮帮我。

如果有人将条令与Symfony一起使用,那就容易多了。只需要2个EventListener,并根据以下要点在服务定义中激活它们-https://gist.github.com/phpfour/4290cc1f0892dda4ef94a492d6b3f81e

我通过执行以下操作解决了问题:

   $em  = $this->getEntityManager();
   $dbh = $em->getConnection();
   $sth = $dbh->prepare("ALTER SESSION SET NLS_TIME_FORMAT = 'HH24:MI:SS' NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS' NLS_TIMESTAMP_FORMAT = 'YYYY-MM-DD HH24:MI:SS' NLS_TIMESTAMP_TZ_FORMAT = 'YYYY-MM-DD HH24:MI:SS TZH:TZM'");
   $sth->execute();