/[Frey]/trunk/lib/Strix/Anketa.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk/lib/Strix/Anketa.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 167 - (hide annotations)
Tue Aug 12 22:00:05 2008 UTC (15 years, 8 months ago) by dpavlin
File size: 1344 byte(s)
model quick poll with options
1 dpavlin 167 package Strix::Anketa;
2    
3     use warnings;
4     use strict;
5    
6     use Strix::Schema;
7     use Fey::ORM::Table;
8    
9     with 'Frey::Collection';
10    
11     use Data::Dump qw/dump/;
12    
13     sub collection_table { 'anketa' }
14    
15     sub t {
16     my $table = shift;
17     warn "## table $table\n";
18     return Strix::Schema->Schema()->table( $table ) || die "can't find $table";
19     }
20    
21     my $anketa = Strix::Schema->Schema()->table( collection_table );
22    
23     has_table( $anketa );
24    
25     my $anketa_pitanja = Strix::Schema->Schema()->table( 'anketa_pitanja' ) or die;
26    
27     my $pitanja =
28     Strix::Schema->SQLFactoryClass()->new_select()
29     ->select( $anketa_pitanja )
30     ->from( $anketa_pitanja )
31     ->where( $anketa_pitanja->column('anketa_id'), '=', Fey::Placeholder->new() )
32     ->order_by( $anketa_pitanja->column('orders'), 'ASC' )
33     # ->limit(5)
34     ;
35    
36    
37     my $fk = Fey::FK->new(
38     source_columns => [ t('anketa')->column('id') ],
39     target_columns => [ t('anketa_pitanja')->column('anketa_id') ],
40     );
41    
42    
43     has_many 'pitanja' => (
44     table => Strix::Schema->Schema()->table( 'anketa_pitanja' ),
45     fk => $fk,
46     # select => $pitanja,
47     # bind_params => sub { $_[0]->id() },
48     );
49    
50     warn dump( map { $_->name } $anketa->columns );
51    
52     package Strix::Anketa::Pitanja;
53    
54     use Strix::Schema;
55     use Fey::ORM::Table;
56    
57     with 'Frey::Collection';
58     sub collection_table { 'anketa_pitanja' }
59     my $table = Strix::Schema->Schema()->table( collection_table );
60     has_table( $table );
61    
62     1;

  ViewVC Help
Powered by ViewVC 1.1.26