Maypole...l::CDBI(3)
π Maypole::Model::CDBI π
okay bestie, this is Maypole::Model::CDBI, from the User Contributed Perl Documentation section, and it's literally the model class that does the heavy lifting so you don't have to π«Ά
β¨ NAME β¨
Maypole::Model::CDBI β the Model class based on Class::DBI. no cap, that's the whole name.
πΈ DESCRIPTION πΈ
so this is the master model class, right? and it outsources all the hard labour to Class::DBI β fetching rows, turning them into objects, all that. it's giving delegation, and honestly? iconic. it's also a genuinely good model to copy if you're swapping it out for other database abstraction modules. like, steal the blueprint, queen π
it implements a base set of methods required for a Maypole Data Model. periodt.
it also inherits accessor and helper methods from Maypole::Model::Base.
when you specify this as the application model, it will use Class::DBI::Loader to generate the model classes straight from the provided database. it's giving β¨automagicβ¨. but if you do not wish to use that functionality, use Maypole::Model::CDBI::Plain instead β that one uses Class::DBI classes provided.
π Untainter
set the class you use to untaint and validate form data. note it must be of type CGI::Untaint::Maypole (which takes a $r arg) or CGI::Untaint.
lowkey important: check that type before you ship it, bestie π
𧬠add_model_superclass
adds model as superclass to model classes (if necessary).
inherited from Maypole::Model::CDBI::Base.
π¬ Action Methods π¬
action methods are methods that are accessed through a web (or other public) interface. like, they're the ones the outside world gets to touch π
inherited from Maypole::Model::CDBI::Base.
βοΈ do_edit
if there is an object in $r->objects, then it should be edited with the parameters in $r->params. otherwise, a new object should be created with those parameters, and put back into $r->objects.
the template should be changed to view, or edit if there were any errors. a hash of errors will be passed to the template.
ποΈ do_delete
inherited from Maypole::Model::CDBI::Base.
this action deletes records. bye bye data, you will be missed π (unless you didn't mean to, in which caseβ¦ good luck bestie)
π do_search
inherited from Maypole::Model::CDBI::Base.
this action method searches for database records.
π list
inherited from Maypole::Model::CDBI::Base.
the list method fills $r->objects with all of the objects in the class. the results are paged using a pager. so many objects, but we stay organised π
π οΈ Helper Methods π οΈ
βοΈ setup
this method is inherited from Maypole::Model::Base and calls setup_database, which uses Class::DBI::Loader to create and load Class::DBI classes from the given database schema.
ποΈ setup_database
the $opts argument is a hashref of options. the options key is a hashref of Database connection options. other keys may be various Loader arguments or flags.
it has this form:
{
# DB connection options
options { AutoCommit => 1 , ... },
# Loader args
relationships => 1,
...
}
π·οΈ class_of
returns class for given table.
π SEE ALSO π
Maypole, Maypole::Model::CDBI::Base.
π AUTHOR π
Maypole is currently maintained by Aaron Trevena.
π AUTHOR EMERITUS π
Simon Cozens, simon#cpan.org
Simon Flack maintained Maypole from 2.05 to 2.09
Sebastian Riedel, sri#oook.de maintained Maypole from 1.99_01 to 2.04
π LICENSE π
You may distribute this code under the same terms as Perl itself.
okay that's the whole page, you ate that π this was Maypole::Model::CDBI(3) from the User Contributed Perl Documentation, and this rendering is from perl v5.42.0, dated 2025-07-25. go forth and model your data, main character π
β¨
π¦ where this page comes from
- fedora 43: perl-Maypole 1:2.13-46.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms