1 package DBIx::Class::CDBICompat;
5 use base qw/DBIx::Class::Core DBIx::Class::DB/;
6 use Carp::Clan qw/^DBIx::Class/;
8 # Modules CDBICompat needs that DBIx::Class does not.
9 my @Extra_Modules = qw(
16 for my $module (@Extra_Modules) {
17 push @didnt_load, $module unless eval qq{require $module};
19 croak("@{[ join ', ', @didnt_load ]} are missing and are required for CDBICompat")
23 __PACKAGE__->load_own_components(qw/
49 #DBIx::Class::ObjIndexStubs
54 DBIx::Class::CDBICompat - Class::DBI Compatibility layer.
59 use base qw/DBIx::Class::CDBICompat/;
61 ...continue as Class::DBI...
65 DBIx::Class features a fully featured compatibility layer with L<Class::DBI>
66 and some common plugins to ease transition for existing CDBI users.
68 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.
73 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.
75 =head3 Class::DBI::AbstractSearch
77 C<search_where()> is fully emulated using DBIC's search. Aside from emulation there's no reason to use C<search_where()>.
79 =head3 Class::DBI::Plugin::NoCache
81 C<nocache> is fully emulated.
83 =head3 Class::DBI::Sweet
85 The features of CDBI::Sweet are better done using DBIC methods which are almost exactly the same. It even uses L<Data::Page>.
87 =head3 Class::DBI::Plugin::DeepAbstractSearch
89 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.
92 =head2 Choosing Features
94 In fact, this class is just a receipe containing all the features emulated.
95 If you like, you can choose which features to emulate by building your
96 own class and loading it like this:
99 __PACKAGE__->load_own_components(qw/CDBICompat/);
101 this will automatically load the features included in My::DB::CDBICompat,
102 provided it looks something like this:
104 package My::DB::CDBICompat;
105 __PACKAGE__->load_components(qw/
106 CDBICompat::ColumnGroups
110 CDBICompat::MightHave
118 The following methods and classes are not emulated, maybe in the future.
122 =item Class::DBI::Query
124 Deprecated in Class::DBI.
126 =item Class::DBI::Column
128 Not documented in Class::DBI. CDBICompat's columns() returns a plain string, not an object.
132 Undocumented CDBI method.
136 =head2 Limited Support
138 The following elements of Class::DBI have limited support.
142 =item Class::DBI::Relationship
144 The semi-documented Class::DBI::Relationship objects returned by C<meta_info($type, $col)> are mostly emulated except for their C<args> method.
148 Relationships between tables (has_a, has_many...) must be delcared 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:
151 use base qw(Class::DBI);
154 Foo->columns( All => qw(this that bar) );
157 use base qw(Class::DBI);
160 Bar->columns( All => qw(up down) );
162 # Now that Foo and Bar are declared it is safe to declare a
163 # relationship between them
164 Foo->has_a( bar => "Bar" );
171 Matt S. Trout <mst@shadowcatsystems.co.uk>
175 You may distribute this code under the same terms as Perl itself.