diff options
| author | yo mama <pepper@scannerjammer.com> | 2014-09-27 17:20:17 -0700 |
|---|---|---|
| committer | yo mama <pepper@scannerjammer.com> | 2014-09-27 17:20:17 -0700 |
| commit | 1cc8609a5976d3f394ac0f36fd1322ee8e6e4eea (patch) | |
| tree | 866f9ebf65e1baeec28b5fc21adcd3d14a8e6bf7 | |
| parent | e7eaa7ff396723ce93d73f275e7ed156d059b07f (diff) | |
added
| -rw-r--r-- | journal_dbic_example.pm | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/journal_dbic_example.pm b/journal_dbic_example.pm new file mode 100644 index 0000000..bef900a --- /dev/null +++ b/journal_dbic_example.pm @@ -0,0 +1,39 @@ +package journalsDBIC; +use Data::Dumper; + +#insert entry by hashref +my $journalentry = $schema->resultset('Journals')->create({ + date => time(), + fulltext => "Hello world", + image_url => "http://something/" +}); + + +#delete by id +my $journalentry = $schema->resultset('Journals')->find({ id => 1 }); +$journalentry->delete(); + +#update by hashref +my $journalentry = $schema->resultset('Journals')->find({ id => 1 }); +$journalentry->update({ + fulltext => "New text here", +}); + +#select by date +my $res = $schema->resultset('Journals')->search({ + -and => [ + date => [ '>', DateTime->now()->subtract({days => 2}) ], + date => [ '<', DateTime->now() ], + ] +}); +foreach my $row ($res->all){ + print Dumper $row; +} + +#select * +#select * from journals basically dump the whole table +my $res = $schema->resultset('Journals') +foreach my $row ($res->all){ + print Dumper { $row->get_columns }; +} +1; |
