[Dbix-class] Newcomer questions ?

Nigel Metheringham nigel.metheringham at dev.intechnology.co.uk
Wed Nov 1 09:21:49 GMT 2006


On 31 Oct 2006, at 18:20, Ivan.Georgiev at uboc.com wrote:

> 1. How do I do direct sql query. (I want to do "TRUNCATE TABLE" for
> now. In Class::DBI it was trought Ima::DBI afaik)

You can get the dbh (DB handle) through $schema->storage->dbi
Thats a DBI object so you can do any DBI operation through it.

In the case of TRUNCATE TABLE it may be worth checking the comparison of
that against DELETE FROM TABLE - if you are doing this without a WHERE
clause the 2 may be equivalent and the DELETE form can be expressed as a
resultset operation.

> 2. How can I save the classes generated from the ::Loader to files on
> disk. (can I do it selectively i.e. save only tables X,Y,Z?).

See dump_to_dir in DBIx::Class::Schema::Loader (and
DBIx::Class::Schema::Loader::Base)

> 3. Is it possible to create table on the fly and after that generate
> class for it, i mean runtime ? an example if possible will be good !

You can create a class and create the table from it. Examples of this
can be found in the DBIx::Class test suite and some documentation in
DBIx::Class::Schema (deploy)

     Nigel.
--
[ Nigel Metheringham           Nigel.Metheringham at InTechnology.co.uk ]
[ - Comments in this message are my own and not ITO opinion/policy - ]






More information about the Dbix-class mailing list