2010-04-23 40 views
3

我有几个DBIx :: Class :: Core对象为各种数据库表建模。在DBIx :: Class中注入关系

对于其中一些模型(那些有'队列'列),我有另一个类注入subs(基本上,'移动'模型对象沿它的队列状态)。

我想也有一流的注入has_many关系ALA

class($name)->has_many('queue_history','MySchema::Result::QueueHistory', 
{ 'foreign.record_id'=>'self.id' }, 
{ where => { type => $name }}); 

,但我似乎无法得到的关系,正确注册(不断收到“无此类关系”的错误 - 但是,当调用源关系方法提供关系)。

任何线索有什么不对?

+0

找到了解决方案,仍然很喜欢看替代品! – Carl 2010-04-23 23:48:17

回答

2

一些周围挖掘,以下工作后:

$class = $schema->class($name)->has_many('queue_history','MySchema::Result::QueueHistory', 
{ 'foreign.record_id'=>'self.id' }, 
{ where => { type => $name }}); 

$schema->unregister_source($name); 
$schema->register_class($name,$class); 

的关键是为了产生所有获得由具有新has_many关系中加入适当的其他方法注销/注册方法。

相关问题