Maypole...l::CDBI(3)

πŸ“¦
version 2.13 Β· 2 versions
, in fedora 43

πŸ’– 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)


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