教条2 oracle datetme列显示“不是有效的月份”插入实体 [英] doctrine 2 oracle datetme column showing "not a valid month" on insert entity
问题描述
我正在使用一个项目,我们使用Zend 2和doctrine 2与oracle数据库。
我的实体有一个字段create_date与datetime类型。我的实体在
I am working on a project where we are using Zend 2 and doctrine 2 with oracle database. my entity has a field create_date with datetime type. my entity are below
class Personnel
{
/**
* @ORM\Column(type="string",unique=true, nullable=false)
*/
protected $login_name;
/**
* @ORM\Column(type="datetime")
*/
protected $create_date;
public function __construct()
{
$this->create_date = new \DateTime("now");
}
public function get_login_name()
{
return $this->login_name;
}
public function set_login_name($login_name)
{
$this->login_name = $login_name;
}
}
并且使用
$user = new Personnel();
$user->set_login_name('Admin');
$this->getEntityManager()->persist($user);
$this->getEntityManager()->flush();
但显示错误
SQLSTATE[HY000]: General error: 1843 OCIStmtExecute: ORA-01843: not a valid month
(ext\pdo_oci\oci_statement.c:148)
请帮助我。
高级thx
推荐答案
在这里也发现这个错误,这是OracleSessionInit不被调用!
Found that bug here too... it's OracleSessionInit not being called!
但是我不知道如果它是一个缺失的配置部分,如果您使用oci8
But i dunno if it's a missing config part or if it's a bug from doctrine not enabling that by default if you use oci8
编辑:
刚刚找到它,那么默认情况下,我应该补充一点,你应该在service_manager的调用者中添加一个指向\Doctrine\DBAL\Event\Listeners\OracleSessionInit的服务,所以应该是这样的:
just found it! and i should add that you should add a service in invokers at service_manager pointing to \Doctrine\DBAL\Event\Listeners\OracleSessionInit, so it should be something like this:
'invokables' => array(
'oracle-session-init' => '\Doctrine\DBAL\Event\Listeners\OracleSessionInit'
),
,这样:
'doctrine' => array (
'driver' => array (
/** here are your driver settings, such as annotations configs */
),
'eventmanager' => array(
'orm_default' => array(
'subscribers' => array('oracle-session-init')
)
)
),
分数:
http://raymondkolbe.com/2012/06/19/doctrineormmodule-and-oraclesessioninit/
这篇关于教条2 oracle datetme列显示“不是有效的月份”插入实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!