1 package DBIx::Class::CDBICompat;
7 require DBIx::Class::Optional::Dependencies;
8 if (my $missing = DBIx::Class::Optional::Dependencies->req_missing_for('cdbicompat')) {
9 die "The following extra modules are required for DBIx::Class::CDBICompat: $missing\n";
13 use base qw/DBIx::Class::Core DBIx::Class::DB/;
15 __PACKAGE__->load_own_components(qw/
47 DBIx::Class::CDBICompat - Class::DBI Compatibility layer.
52 use base qw/DBIx::Class::CDBICompat/;
54 ...continue as Class::DBI...
58 DBIx::Class features a fully featured compatibility layer with L<Class::DBI>
59 and some common plugins to ease transition for existing CDBI users.
61 This is not a wrapper or subclass of DBIx::Class but rather a series of plugins. The result being that even though you're using the Class::DBI emulation layer you are still getting DBIx::Class objects. You can use all DBIx::Class features and methods via CDBICompat. This allows you to take advantage of DBIx::Class features without having to rewrite your CDBI code.
66 CDBICompat is good enough that many CDBI plugins will work with CDBICompat, but many of the plugin features are better done with DBIx::Class methods.
68 =head3 Class::DBI::AbstractSearch
70 C<search_where()> is fully emulated using DBIC's search. Aside from emulation there's no reason to use C<search_where()>.
72 =head3 Class::DBI::Plugin::NoCache
74 C<nocache> is fully emulated.
76 =head3 Class::DBI::Sweet
78 The features of CDBI::Sweet are better done using DBIC methods which are almost exactly the same. It even uses L<Data::Page>.
80 =head3 Class::DBI::Plugin::DeepAbstractSearch
82 This plugin will work, but it is more efficiently done using DBIC's native search facilities. The major difference is that DBIC will not infer the join for you, you have to tell it the join tables.
85 =head2 Choosing Features
87 In fact, this class is just a recipe containing all the features emulated.
88 If you like, you can choose which features to emulate by building your
89 own class and loading it like this:
92 __PACKAGE__->load_own_components(qw/CDBICompat/);
94 this will automatically load the features included in My::DB::CDBICompat,
95 provided it looks something like this:
97 package My::DB::CDBICompat;
98 __PACKAGE__->load_components(qw/
99 CDBICompat::ColumnGroups
103 CDBICompat::MightHave
111 The following methods and classes are not emulated, maybe in the future.
115 =item Class::DBI::Query
117 Deprecated in Class::DBI.
119 =item Class::DBI::Column
121 Not documented in Class::DBI. CDBICompat's columns() returns a plain string, not an object.
125 Undocumented CDBI method.
129 =head2 Limited Support
131 The following elements of Class::DBI have limited support.
135 =item Class::DBI::Relationship
137 The semi-documented Class::DBI::Relationship objects returned by C<meta_info($type, $col)> are mostly emulated except for their C<args> method.
141 Relationships between tables (has_a, has_many...) must be declared after all tables in the relationship have been declared. Thus the usual CDBI idiom of declaring columns and relationships for each class together will not work. They must instead be done like so:
144 use base qw(Class::DBI);
147 Foo->columns( All => qw(this that bar) );
150 use base qw(Class::DBI);
153 Bar->columns( All => qw(up down) );
155 # Now that Foo and Bar are declared it is safe to declare a
156 # relationship between them
157 Foo->has_a( bar => "Bar" );
162 =head1 FURTHER QUESTIONS?
164 Check the list of L<additional DBIC resources|DBIx::Class/GETTING HELP/SUPPORT>.
166 =head1 COPYRIGHT AND LICENSE
168 This module is free software L<copyright|DBIx::Class/COPYRIGHT AND LICENSE>
169 by the L<DBIx::Class (DBIC) authors|DBIx::Class/AUTHORS>. You can
170 redistribute it and/or modify it under the same terms as the
171 L<DBIx::Class library|DBIx::Class/COPYRIGHT AND LICENSE>.