Using DBIC 0.07, I have some code that does something along the lines of 
the following:

package My::Schema::User;
__PACKAGE__->add_columns(qw/ id name tel /);
__PACKAGE__->set_primary_key('id'); # 'id' is an auto incrementing column

# elsewhere...

# get an empty resultset
$rs = $schema->resultset('User')->search( { id => undef } );

$rs->count; # runs something like "SELECT ... FROM user WHERE me.id IS 
NULL" and returns 0

# insert a new record in "user" table ( "id" column is auto populated )
$row = $rs->update_or_create( { name => 'name', tel => '11' }, { key => 
'primary' } );

$rs->count; # runs same query as before so still returns 0

Probably a silly question, but it's late in the afternoon and my brain's 
tired. I want to keep hold of a resultset containing the newly created 
record for use elsewhere in my application, i.e. in the above case I'd 
like $rs->count to return 1 and $rs->first to return the new record. Is 
there a way to get the resultset to auto-update its query as new records 
are added? Or do I need to create a new resultset to be able to do this?

_______________________________________________
List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
Wiki: http://dbix-class.shadowcatsystems.co.uk/
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
Searchable Archive: http://www.mail-archive.com/[email protected]/

Reply via email to