DBIx::Class 基结果类
我正在尝试使用 DBIx::Class::Schema::Loader 为 Catalyst 创建模型。我希望结果类有一个可以添加方法的基类。所以MyTable.pm继承自Base.pm,而Base.pm继承自DBIx::Class::core(默认)。
不知怎的,我不知道该怎么做。我的创建脚本如下,谁能告诉我我做错了什么?该脚本可以正常创建我的模型,但所有结果集类都直接从 DBIx::Class::core 继承,中间没有我的基类。
#!/usr/bin/perl
use DBIx::Class::Schema::Loader qw/ make_schema_at /;
#specifically for the entities many-2-many relation
$ENV{DBIC_OVERWRITE_HELPER_METHODS_OK} = 1;
make_schema_at(
'MyApp::Schema',
{
dump_directory => '/tmp',
debug => 1,
overwrite_modifications => 1,
components => ['EncodedColumn'], #encoded password column
use_namespaces => 1,
default_resultset_class => 'Base'
},
[ 'DBI:mysql:database=mydb;host=localhost;port=3306','rob', '******' ],
);
I am trying to create a model for Catalyst by using DBIx::Class::Schema::Loader. I want the result classes to have a base class I can add methods to. So MyTable.pm inherits from Base.pm which inherits from DBIx::Class::core (default).
Somehow I cannot figure out how to do this. my create script is below, can anyone tell me what I am doing wrong? The script creates my model ok, but all resultset classes just directly inherit from DBIx::Class::core without my Base class in between.
#!/usr/bin/perl
use DBIx::Class::Schema::Loader qw/ make_schema_at /;
#specifically for the entities many-2-many relation
$ENV{DBIC_OVERWRITE_HELPER_METHODS_OK} = 1;
make_schema_at(
'MyApp::Schema',
{
dump_directory => '/tmp',
debug => 1,
overwrite_modifications => 1,
components => ['EncodedColumn'], #encoded password column
use_namespaces => 1,
default_resultset_class => 'Base'
},
[ 'DBI:mysql:database=mydb;host=localhost;port=3306','rob', '******' ],
);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来您只想添加
result_base_class
(并且可能删除default_resultset_class
) -更新,相关文档:DBIx::Class::Schema::Loader::Base#result_base_class。
Looks like you just want to add in
result_base_class
(and probably drop thedefault_resultset_class
)–Update, relevant doc: DBIx::Class::Schema::Loader::Base#result_base_class.