Matt S Trout wrote:
On Sun, Jan 13, 2008 at 04:47:38PM +0300, Alex Povolotsky wrote:
Hello!

In Tutorial (BTW, "CRUD" section of tutorial lacks U completely), I've seen this way of filling in the record:

   my $book = $c->model('GalleryDB::Gallery')->new({});
   $book->populate_from_widget($result);

which sets a bunch of data and then calls $book->insert_or_update;

In InstantCRUD data is filled in with

my $item = $result->save_to_db();

I have no idea how this works.
It seems to obtain $result with

my $result = $w->action( $c->uri_for('do_add') )->process( $c->request );

And $result is a HTML::Widget::Result::DBIC instance, so save_to_db is

"HTML::Widget::DBIC::Result method to save the data from widget to
the database"

Neither of these are standard DBIx::Class methods; the standard approach
is to do

my $obj = $rs->new(\%data);

<maybe use $obj->column_name($value) to set more data>

$obj->insert;

DBIx::Class::ResultSet provides a $rs->create(\%data) shortcut that calls
$obj->insert for you before returning it, but that really is just a
shortcut - the end effect is identical.

For more info, have a look at the DBIx::Class documentation on CPAN and
note that DBIC-specific questions can be asked on the dedicated dbix-class
list.

Thanks a lot. I'll go read it. There is such a lot of useful Perl modues...

Alex.


_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to