Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tokuhirom/dbix-kohada
https://github.com/tokuhirom/dbix-kohada
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/tokuhirom/dbix-kohada
- Owner: tokuhirom
- Created: 2010-11-26T07:52:06.000Z (almost 14 years ago)
- Default Branch: master
- Last Pushed: 2010-12-25T02:09:55.000Z (almost 14 years ago)
- Last Synced: 2024-05-09T19:17:50.950Z (6 months ago)
- Language: Perl
- Homepage:
- Size: 305 KB
- Stars: 10
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
- Changelog: Changes
Awesome Lists containing this project
README
NAME
DBIx::Kohada -SYNOPSIS
package MyApp::DB;
use base qw/DBIx::Kohada/;
__PACKAGE__->schema_class('MyApp::DB::Schema');package MyApp::DB::Schema;
use base qw/DBIx::Kohada::Schema/;__PACKAGE__->register_row_class(
class => 'MyApp::DB::User',
table => 'user',
columns => [qw/user_id name email/],
pk => 'user_id',
);package MyApp::DB::User;
use base qw/DBIx::Kohada::Row/;__PACKAGE__->add_trigger(
'BEFORE_INSERT' => sub {
my $attr = shift;
$attr->{token} ||= rand();
}
);package main;
use MyApp::DB::Schema;
use DBIx::Kohada::Schema;
use DBI;my $dbh = DBI->connect(...);
my $db = MyApp::DB->new(dbh => $dbh);
$db->dbh; # => #dbh
my $user = $db->insert('user' => {name => 'john', email => '[email protected]'});
say $user->name; # => john
$user->name('mark');
$user->update;
$user->delete();my @users = $db->search_by_sql('user' => q{SELECT * FROM user WHERE name LIKE 'dai%'});
my $user = $db->single('user' => {user_id => 3});
my $iter = $db->search('user' => {user_id => 3});
my @users = $db->search('user' => {user_id => 3});DESCRIPTION
DBIx::Kohada isTODO
trigger supportBEFORE_INSERT
AFTER_INSERT
BEFORE_UPDATE
AFTER_UPDATE
BEFORE_DELETE
AFTER_DELETEAUTHOR
Tokuhiro MatsunoSEE ALSO
LICENSE
Copyright (C) Tokuhiro MatsunoThis library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.