[Dbix-class] Migration from Class::DBI: Delete all table entries?

Matt S Trout dbix-class at trout.me.uk
Tue Jun 27 19:08:37 CEST 2006


Steven Mackenzie wrote:
> In some Class::DBI code, I have this in my table base class:
> 
> __PACKAGE__->set_sql("delete_all", <<"");
> DELETE FROM __TABLE__ WHERE 1=1

$schema->resultset('TableName')->delete;

will issue that query.

There's also an ->delete_all method on ResultSet which fetches the objects and 
calls ->delete on each one, should you need that.

> Also, is it safe/recommended to borrow the DB connection from a
> DBIxC::Schema or table row instance?

Usually, you don't need to do that. If you're sure you do then calling ->dbh 
on the $storage is fine.

-- 
      Matt S Trout       Offering custom development, consultancy and support
   Technical Director    contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

+ Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +



More information about the Dbix-class mailing list