<?xml version="1.0" encoding="windows-1252"?>
<node id="557434" title="Re^2: Class::DBI vs. DBIx::Class" created="2006-06-25 10:46:09" updated="2006-06-25 06:46:09">
<type id="11">
note</type>
<author id="557401">
hrr</author>
<data>
<field name="doctext">
Now I understand that DBIx::Class is more flexible than Class::DBI!  On the other hand, this comes at the price of longer code for simple tasks, e.g., for inserting into a table &lt;code&gt;'Person'&lt;/code&gt;, one would use
&lt;code&gt;
# using DBIx::Class:  
$schema-&gt;resultset('Person')-&gt;new({FirstName=&gt;'Joe'})-&gt;insert();   

# using Class::DBI:
DB::Person-&gt;insert({FirstName=&gt;'Joe'});
&lt;/code&gt;
Nevertheless, the greater flexibility motivated me to try DBIx::Class, too.  What still bothers me is that 
&lt;code&gt;
package DB::Person;
use base 'DBIx::Class';
__PACKAGE__-&gt;load_components(qw/PK::Auto Core/);
__PACKAGE__-&gt;table('T_PERSON');
__PACKAGE__-&gt;add_columns(qw[PersonId FirstName]);
__PACKAGE__-&gt;set_primary_key('PersonId');

package DB;
use base 'DBIx::Class::Schema';
__PACKAGE__-&gt;load_classes(qw[Person]);
&lt;/code&gt;
fails with &lt;i&gt;Can't locate object method "result_source_instance" via package "DB/Person" (perhaps you forgot to load "DB/Person"?) at c:/Perl/site/lib/DBIx/Class/Schema.pm line 75.&lt;/i&gt;  If I put the definition of &lt;code&gt;DB::Person&lt;/code&gt; into &lt;code&gt;DB/Person.pm&lt;/code&gt;, it works, but is far less elegant/compact.  Is there a smarter solution?</field>
<field name="root_node">
557402</field>
<field name="parent_node">
557422</field>
</data>
</node>
