-
-
17 May 2022 10:49:29 UTC
- Distribution: DBIx-Class
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Repository
- Issues (121)
- Testers (1158 / 3 / 0)
- Kwalitee
Bus factor: 1- % Coverage
- License: perl_5
- Perl: v5.8.1
- Activity
24 month- Tools
- Download (858.78KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
and 210 contributors-
mst: Matt S Trout (project founder - original idea, architecture and implementation)
-
castaway: Jess Robinson (lions share of the reference documentation and manuals)
-
abraxxa: Alexander Hartmaier
-
acca: Alexander Kuznetsov
-
acme: Leon Brocard
-
aherzog: Adam Herzog
-
Alexander Keusch
-
alexrj: Alessandro Ranellucci
-
alnewkirk: Al Newkirk
-
Altreus: Alastair McGowan-Douglas
-
amiri: Amiri Barksdale
-
amoore: Andrew Moore
-
Andrew Mehta
-
andrewalker: Andre Walker
-
andyg: Andy Grundman
-
ank: Andres Kievsky
-
arc: Aaron Crane
-
arcanez: Justin Hunter
-
ash: Ash Berlin
-
bert: Norbert Csongrádi
-
bfwg: Colin Newell
-
blblack: Brandon L. Black
-
bluefeet: Aran Deltac
-
boghead: Bryan Beeley
-
bphillips: Brian Phillips
-
brd: Brad Davis
-
Brian Kirkbride
-
bricas: Brian Cassidy
-
brunov: Bruno Vecchi
-
caelum: Rafael Kitover
-
caldrin: Maik Hentsche
-
chorny: Alexandr Ciornii
-
cj: C.J. Adams-Collier
-
claco: Christopher H. Laco
-
clkao: CL Kao
- Ctrl-O http://ctrlo.com/
-
da5id: David Jack Olrik
-
dams: Damien Krotkine
-
dandv: Dan Dascalescu
-
dariusj: Darius Jokilehto
-
davewood: David Schmidt
-
daxim: Lars Dɪᴇᴄᴋᴏᴡ 迪拉斯
-
dduncan: Darren Duncan
-
debolaz: Anders Nor Berle
-
dew: Dan Thomas
-
dim0xff: Dmitry Latin
-
dkubb: Dan Kubb
-
dnm: Justin Wheeler
-
dpetrov: Dimitar Petrov
-
Dr^ZigMan: Robert Stone
-
dsteinbrunner: David Steinbrunner
-
duncan_dmg: Duncan Garland
-
dwc: Daniel Westermann-Clark
-
dyfrgi: Michael Leuchtenburg
-
edenc: Eden Cardim
- Eligo http://eligo.co.uk/
-
ether: Karen Etheridge
-
evdb: Edmund von der Burg
-
faxm0dem: Fabien Wernli
-
felliott: Fitz Elliott
-
fgabolde: Fabrice Gabolde
-
freetime: Bill Moseley
-
frew: Arthur Axel "fREW" Schmidt
-
gbjk: Gareth Kirwan
-
geotheve: Georgina Thevenet
-
Getty: Torsten Raudssus
-
goraxe: Gordon Irving
-
gphat: Cory G Watson
- Grant Street Group http://www.grantstreet.com/
-
gregoa: Gregor Herrmann
-
groditi: Guillermo Roditi
-
gshank: Gerda Shank
-
guacamole: Fred Steinberg
-
Haarg: Graham Knop
-
hobbs: Andrew Rodland
-
Ian Wells
-
idn: Ian Norton
-
ilmari: Dagfinn Ilmari Mannsåker
-
ingy: Ingy döt Net
-
initself: Mike Baas
-
ironcamel: Naveed Massjouni
-
jasonmay: Jason May
-
jawnsy: Jonathan Yu
-
jegade: Jens Gassmann
-
jeneric: Eric A. Miller
-
jesper: Jesper Krogh
-
Jesse Sheidlower
-
jgoulah: John Goulah
-
jguenther: Justin Guenther
-
jhannah: Jay Hannah
-
jmac: Jason McIntosh
-
jmmills: Jason M. Mills
-
jnapiorkowski: John Napiorkowski
-
Joe Carlson
-
jon: Jon Schutz
-
Jordan Metzmeier
-
jshirley: J. Shirley
- kaare: Kaare Rasmussen
-
kd: Kieren Diment
-
kentnl: Kent Fredric
-
kkane: Kevin L. Kane
-
konobi: Scott McWhirter
-
lejeunerenard: Sean Zellmer
-
leont: Leon Timmermans
-
littlesavage: Alexey Illarionov
-
lukes: Luke Saunders
-
marcus: Marcus Ramberg
-
mateu: Mateu X. Hunter
-
Matt LeBlanc
-
Matt Sickler
- mattlaw: Matt Lawrence
-
mattp: Matt Phillips
-
mdk: Mark Keating
-
melo: Pedro Melo
-
metaperl: Terrence Brannon
-
michaelr: Michael Reddick
-
milki: Jonathan Chu
-
minty: Murray Walker
-
mithaldu: Christian Walde
-
mjemmeson: Michael Jemmeson
- mna: Maya
-
mo: Moritz Onken
-
moltar: Roman Filippov
-
moritz: Moritz Lenz
-
mrf: Mike Francis
-
mstratman: Mark A. Stratman
-
ned: Neil de Carteret
-
nigel: Nigel Metheringham
-
ningu: David Kamholz
-
Nniuq: Ron "Quinn" Straight"
-
norbi: Norbert Buchmuller
-
nothingmuch: Yuval Kogman
-
nuba: Nuba Princigalli
-
Numa: Dan Sully
-
oalders: Olaf Alders
-
Olly Betts
-
osfameron: Hakim Cassimally
-
ovid: Curtis "Ovid" Poe
-
oyse: Øystein Torget
-
paulm: Paul Makepeace
-
penguin: K J Cheetham
-
perigrin: Chris Prather
-
Peter Siklósi
-
Peter Valdemar Mørch
-
peter: Peter Collingbourne
-
phaylon: Robert Sedlacek
-
plu: Johannes Plunien
-
pmooney: Paul Mooney
-
Possum: Daniel LeWarne
-
pplu: Jose Luis Martinez
-
quicksilver: Jules Bean
-
racke: Stefan Hornburg
-
rafl: Florian Ragwitz
-
rainboxx: Matthias Dietrich
-
rbo: Robert Bohne
-
rbuels: Robert Buels
-
rdj: Ryan D Johnson
-
Relequestual: Ben Hutton
-
renormalist: Steffen Schwigon
-
rjbs: Ricardo Signes
-
Robert Krimen
-
Robert Olson
-
robkinyon: Rob Kinyon
-
Roman Ardern-Corris
-
ruoso: Daniel Ruoso
-
Sadrak: Felix Antonius Wilhelm Ostmann
- sc_: Just Another Perl Hacker
-
schwern: Michael G Schwern
-
Scott R. Godin
-
scotty: Scotty Allen
-
semifor: Marc Mims
-
Simon Elliott
-
SineSwiper: Brendan Byrd
-
skaufman: Samuel Kaufman
-
solomon: Jared Johnson
-
spb: Stephen Bennett
-
Squeeks
-
srezic: Slaven Rezic
-
sszabo: Stephan Szabo
-
Stephen Peters
-
stonecolddevin: Devin Austin
-
talexb: Alex Beamish
-
tamias: Ronald J Kimball
-
TBSliver: Tom Bloor
-
teejay: Aaron Trevena
-
theorbtwo: James Mastros
-
Thomas Kratz
-
timbunce: Tim Bunce
-
tinita: Tina Mueller
- Todd Lipcon
-
Tom Hukins
-
tommy: Tommy Butler
-
tonvoon: Ton Voon
-
triode: Pete Gamache
-
typester: Daisuke Murase
-
uree: Oriol Soriano
-
uwe: Uwe Voelker
-
vanstyn: Henry Van Styn
-
victori: Victor Igumnov
-
wdh: Will Hawes
-
wesm: Wes Malone
-
willert: Sebastian Willert
-
wintermute: Toby Corkindale
-
wreis: Wallace Reis
-
x86-64
-
xenoterracide: Caleb Cushing
-
xmikew: Mike Wisener
-
yrlnry: Mark Jason Dominus
-
zamolxes: Bogdan Lucaciu
-
Zefram: Andrew Main
- Dependencies
- Class::Accessor::Grouped
- Class::C3::Componentised
- Class::Inspector
- Config::Any
- Context::Preserve
- DBI
- Data::Dumper::Concise
- Devel::GlobalDestruction
- Hash::Merge
- MRO::Compat
- Module::Find
- Moo
- Path::Class
- SQL::Abstract::Classic
- Scope::Guard
- Sub::Name
- Text::Balanced
- Try::Tiny
- namespace::clean
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
DBIx::Class::Manual::Example - Simple CD database example
DESCRIPTION
This tutorial will guide you through the process of setting up and testing a very basic CD database using SQLite, with DBIx::Class::Schema as the database frontend.
The database structure is based on the following rules:
An artist can have many cds, and each cd belongs to just one artist. A cd can have many tracks, and each track belongs to just one cd.
The database is implemented with the following:
table 'artist' with columns: artistid, name table 'cd' with columns: cdid, artistid, title, year table 'track' with columns: trackid, cdid, title
Each of the table's first columns is the primary key; any subsequent keys are foreign keys.
Installation
You'll need to install DBIx::Class via CPAN, and you'll also need to install sqlite3 (not sqlite) if it's not already intalled.
The database/tables/data
Your distribution already comes with a pre-filled SQLite database examples/Schema/db/example.db. You can see it by e.g.
cpanm --look DBIx::Class
If for some reason the file is unreadable on your system, you can recreate it as follows:
cp -a <unpacked-DBIC-tarball>/examples/Schema dbicapp cd dbicapp rm db/example.db sqlite3 db/example.db < db/example.sql perl insertdb.pl
Testing the database
Enter the example Schema directory
cd <unpacked-DBIC-tarball>/examples/Schema
Run the script testdb.pl, which will test that the database has successfully been filled.
When this script is run, it should output the following:
get_tracks_by_cd(Bad): Leave Me Alone Smooth Criminal Dirty Diana get_tracks_by_artist(Michael Jackson): Billie Jean (from the CD 'Thriller') Beat It (from the CD 'Thriller') Leave Me Alone (from the CD 'Bad') Smooth Criminal (from the CD 'Bad') Dirty Diana (from the CD 'Bad') get_cd_by_track(Stan): The Marshall Mathers LP has the track 'Stan'. get_cds_by_artist(Michael Jackson): Thriller Bad get_artist_by_track(Dirty Diana): Michael Jackson recorded the track 'Dirty Diana'. get_artist_by_cd(The Marshall Mathers LP): Eminem recorded the CD 'The Marshall Mathers LP'.
Discussion about the results
The data model defined in this example has an artist with multiple CDs, and a CD with multiple tracks; thus, it's simple to traverse from a track back to a CD, and from there back to an artist. This is demonstrated in the get_tracks_by_artist routine, where we easily walk from the individual track back to the title of the CD that the track came from ($track->cd->title).
Note also that in the get_tracks_by_cd and get_tracks_by_artist routines, the result set is called multiple times with the 'next' iterator. In contrast, get_cd_by_track uses the 'first' result set method, since only one CD is expected to have a specific track.
This example uses "load_namespaces" in DBIx::Class::Schema to load in the appropriate Result classes from the
MyApp::Schema::Result
namespace, and any required ResultSet classes from theMyApp::Schema::ResultSet
namespace (although we did not add, nor needed any such classes in this example).FURTHER QUESTIONS?
Check the list of additional DBIC resources.
COPYRIGHT AND LICENSE
This module is free software copyright by the DBIx::Class (DBIC) authors. You can redistribute it and/or modify it under the same terms as the DBIx::Class library.
Module Install Instructions
To install DBIx::Class, copy and paste the appropriate command in to your terminal.
cpanm DBIx::Class
perl -MCPAN -e shell install DBIx::Class
For more information on module installation, please visit the detailed CPAN module installation guide.