Skip to content

Commit

Permalink
DBと連携してみる
Browse files Browse the repository at this point in the history
  • Loading branch information
Nishibayashi Takuji committed Jan 28, 2011
1 parent efb3d2d commit 492f45a
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 31 deletions.
34 changes: 4 additions & 30 deletions assets/template/root/test.html
Expand Up @@ -10,38 +10,12 @@
var dataStore = new Ext.data.Store({
model: 'Conversation',
data: [
: while $iter.next -> $d{
{
id : 1,
body: 'おい',
},
{
id : 2,
body: 'こら',
},
{
id : 3,
body: 'これは',
},
{
id : 4,
body: 'テスト',
},
{
id : 5,
body: 'です',
},
{
id : 6,
body: 'おい',
},
{
id : 7,
body: 'きいてんのか',
},
{
id : 8,
body: 'おい',
id: <: $d.id() :>,
body: '<: $d.body() :>',
},
: }
]
});

Expand Down
7 changes: 7 additions & 0 deletions lib/SenchaStudy/Container.pm
@@ -1,6 +1,13 @@
package SenchaStudy::Container;
use Chiffon::Core;
use Chiffon::Container -base;
use SenchaStudy::Model::DB;

register 'db' => sub {
my $self = shift;
my $conf = $self->get('conf');
SenchaStudy::Model::DB->new($conf->{datasource}->{master});
};

1;

8 changes: 8 additions & 0 deletions lib/SenchaStudy/Model/DB.pm
@@ -0,0 +1,8 @@
package SenchaStudy::Model::DB;
use strict;
use warnings;
use utf8;
use DBIx::Skinny;
use DBIx::Skinny::Mixin modules => ['SearchWithPager'];

1;
14 changes: 14 additions & 0 deletions lib/SenchaStudy/Model/DB/Schema.pm
@@ -0,0 +1,14 @@
package SenchaStudy::Model::DB::Schema;
use strict;
use warnings;
use utf8;
use DBIx::Skinny::Schema;

install_table conversation => schema {
pk 'id';
columns qw/id body/;
};

install_utf8_columns qw/body/;

1;
12 changes: 11 additions & 1 deletion lib/SenchaStudy/Web/C/Root.pm
Expand Up @@ -12,7 +12,17 @@ sub do_slide {
my ( $class, $c ) = @_;
}

sub do_test{}
sub do_test{
my ( $class, $c ) = @_;
my $con = container('db')->search(
'conversation',
{},
{
order_by => { id => 'asc' }
},
);
$c->stash->{iter} = $con;
}

sub do_slide_list {
my ( $class, $c ) = @_;
Expand Down

0 comments on commit 492f45a

Please sign in to comment.