.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "DBIx::Class::ResultSource::View 3pm" .TH DBIx::Class::ResultSource::View 3pm "2022-05-21" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" DBIx::Class::ResultSource::View \- ResultSource object representing a view .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& package MyApp::Schema::Result::Year2000CDs; \& \& use base qw/DBIx::Class::Core/; \& \& _\|_PACKAGE_\|_\->table_class(\*(AqDBIx::Class::ResultSource::View\*(Aq); \& \& _\|_PACKAGE_\|_\->table(\*(Aqyear2000cds\*(Aq); \& _\|_PACKAGE_\|_\->result_source_instance\->is_virtual(1); \& _\|_PACKAGE_\|_\->result_source_instance\->view_definition( \& "SELECT cdid, artist, title FROM cd WHERE year =\*(Aq2000\*(Aq" \& ); \& _\|_PACKAGE_\|_\->add_columns( \& \*(Aqcdid\*(Aq => { \& data_type => \*(Aqinteger\*(Aq, \& is_auto_increment => 1, \& }, \& \*(Aqartist\*(Aq => { \& data_type => \*(Aqinteger\*(Aq, \& }, \& \*(Aqtitle\*(Aq => { \& data_type => \*(Aqvarchar\*(Aq, \& size => 100, \& }, \& ); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" View object that inherits from DBIx::Class::ResultSource .PP This class extends ResultSource to add basic view support. .PP A view has a \*(L"view_definition\*(R", which contains a \s-1SQL\s0 query. The query can only have parameters if \*(L"is_virtual\*(R" is set to true. It may contain JOINs, sub selects and any other \s-1SQL\s0 your database supports. .PP View definition \s-1SQL\s0 is deployed to your database on \&\*(L"deploy\*(R" in DBIx::Class::Schema unless you set \*(L"is_virtual\*(R" to true. .PP Deploying the view does \fBnot\fR translate it between different database syntaxes, so be careful what you write in your view \s-1SQL.\s0 .PP Virtual views (\*(L"is_virtual\*(R" true), are assumed to not exist in your database as a real view. The \*(L"view_definition\*(R" in this case replaces the view name in a \s-1FROM\s0 clause in a subselect. .SH "EXAMPLES" .IX Header "EXAMPLES" Having created the MyApp::Schema::Year2000CDs schema as shown in the \s-1SYNOPSIS\s0 above, you can then: .PP .Vb 6 \& $2000_cds = $schema\->resultset(\*(AqYear2000CDs\*(Aq) \& \->search() \& \->all(); \& $count = $schema\->resultset(\*(AqYear2000CDs\*(Aq) \& \->search() \& \->count(); .Ve .PP If you modified the schema to include a placeholder .PP .Vb 3 \& _\|_PACKAGE_\|_\->result_source_instance\->view_definition( \& "SELECT cdid, artist, title FROM cd WHERE year = ?" \& ); .Ve .PP and ensuring you have is_virtual set to true: .PP .Vb 1 \& _\|_PACKAGE_\|_\->result_source_instance\->is_virtual(1); .Ve .PP You could now say: .PP .Vb 6 \& $2001_cds = $schema\->resultset(\*(AqYear2000CDs\*(Aq) \& \->search({}, { bind => [2001] }) \& \->all(); \& $count = $schema\->resultset(\*(AqYear2000CDs\*(Aq) \& \->search({}, { bind => [2001] }) \& \->count(); .Ve .SH "SQL EXAMPLES" .IX Header "SQL EXAMPLES" .IP "is_virtual set to false" 4 .IX Item "is_virtual set to false" .Vb 1 \& $schema\->resultset(\*(AqYear2000CDs\*(Aq)\->all(); \& \& SELECT cdid, artist, title FROM year2000cds me .Ve .IP "is_virtual set to true" 4 .IX Item "is_virtual set to true" .Vb 1 \& $schema\->resultset(\*(AqYear2000CDs\*(Aq)\->all(); \& \& SELECT cdid, artist, title FROM \& (SELECT cdid, artist, title FROM cd WHERE year =\*(Aq2000\*(Aq) me .Ve .SH "METHODS" .IX Header "METHODS" .SS "is_virtual" .IX Subsection "is_virtual" .Vb 1 \& _\|_PACKAGE_\|_\->result_source_instance\->is_virtual(1); .Ve .PP Set to true for a virtual view, false or unset for a real database-based view. .SS "view_definition" .IX Subsection "view_definition" .Vb 3 \& _\|_PACKAGE_\|_\->result_source_instance\->view_definition( \& "SELECT cdid, artist, title FROM cd WHERE year =\*(Aq2000\*(Aq" \& ); .Ve .PP An \s-1SQL\s0 query for your view. Will not be translated across database syntaxes. .SS "deploy_depends_on" .IX Subsection "deploy_depends_on" .Vb 3 \& _\|_PACKAGE_\|_\->result_source_instance\->deploy_depends_on( \& ["MyApp::Schema::Result::Year","MyApp::Schema::Result::CD"] \& ); .Ve .PP Specify the views (and only the views) that this view depends on. Pass this an array reference of fully qualified result classes. .SH "OVERRIDDEN METHODS" .IX Header "OVERRIDDEN METHODS" .SS "from" .IX Subsection "from" Returns the \s-1FROM\s0 entry for the table (i.e. the view name) or the \s-1SQL\s0 as a subselect if this is a virtual view. .SH "OTHER METHODS" .IX Header "OTHER METHODS" .SS "new" .IX Subsection "new" The constructor. .SH "FURTHER QUESTIONS?" .IX Header "FURTHER QUESTIONS?" Check the list of additional \s-1DBIC\s0 resources. .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This module is free software copyright by the DBIx::Class (\s-1DBIC\s0) authors. You can redistribute it and/or modify it under the same terms as the DBIx::Class library.