[Dbix-class] Migration from Class::DBI: Delete all table entries?
Steven Mackenzie
dbix at aptile.co.uk
Wed Jun 28 16:25:41 CEST 2006
Matt S Trout wrote:
>A. Pagaltzis wrote:
>
>
>>>__PACKAGE__->set_sql("delete_all", <<"");
>>>DELETE FROM __TABLE__ WHERE 1=1
>>>
>>>
>>Note that you can omit that `WHERE` clause completely. It’s legal
>>syntax to say `DELETE FROM $table`.
>>
>>
>
>Which is exactly what DBIx::Class will do given the code snippet in my last
>message :)
>
>
>
Hmm -- I'm not sure if I had a good reason for the WHERE 1=1, although I
think I tried it without first.
Maybe it was needed to stop CDBI putting a where clause in, or maybe it
was superstition, or I just thought it looked big and clever? Thanks for
your input -- it's all helpful to me!
Elsewhere, Matt S T wrote:
> Right. DBIC makes this easier for main usage by allowing schema objects
(multiple connections per class tree :D).
Yup, I like that, and also the slightly more obvious class/instance
seperation in DBIxC vs CDBI. (As much as I find any Perl "obvious", anyway.)
Also like that I can swap between DBs (SQLite -> MSSQL) just by changing
the DSN, in CDBI I was using a different base class to get the autoinc
columns working.
However, it's a bit slow joining all the DBIxC bits together in my head
-- is there a class diagram somewhere? [not sure if I'm joking or not :-/ ]
Steven
More information about the Dbix-class
mailing list