Permalink
Browse files

DBと連携してみる

  • Loading branch information...
1 parent efb3d2d commit 492f45a8517bd85cdfdbc00d62d07bf129075d98 Nishibayashi Takuji committed Jan 28, 2011
View
34 assets/template/root/test.html
@@ -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() :>',
},
+: }
]
});
View
7 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;
View
8 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;
View
14 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;
View
12 lib/SenchaStudy/Web/C/Root.pm
@@ -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 ) = @_;

0 comments on commit 492f45a

Please sign in to comment.