[Dbix-class] Extra columns in data for update/create
Trevor Phillips
trevor.phillips at gmail.com
Fri Mar 13 02:22:03 GMT 2009
I frequently find when making webapps that I may have a complex web
form which submits many fields intended to be stored across several
tables. I would prefer to just translate all those parameters into a
single hash, and pass that hash to DBIx for creating/updating records.
ie; If I transfer all submitted form parameters into a hash called
%Data, I would then like to simply go:
$c->model('DB::OneTable')->create(\%Data);
(This is a Catalyst app...)
The problem here is that methods like create expect all key/value
pairs passed in to match column names, so any extra fields cause it to
fail with a "No such column" error.
Is there an easy and efficient way to either tell methods like create
to ignore extra columns passed in, or to filter %Data to only include
columns in the table?
Currently I am having to specify columns manually, and I need my
Catalyst Controllers to handle data without caring what the full
column list is.
--
Trevor Phillips - http://dortamur.livejournal.com/
"On nights such as this, evil deeds are done. And good deeds, of
course. But mostly evil, on the whole."
-- (Terry Pratchett, Wyrd Sisters)
More information about the DBIx-Class
mailing list