Karas - Yet another O/R Mapper.
use Karas; my $db = Karas->new(connect_info => ['dbi:SQLite::memory:', '', '']); $db->dbh->do(q{CREATE TABLE member (id int, name varchar(255) not null)}); my $member = $db->insert('member' => { name => 'John', }); $db->update($member, { name => 'Mills', }); $member = $db->refetch($member);
Karas is yet another O/R mapper.
THIS IS A DEVELOPMENT RELEASE. API MAY CHANGE WITHOUT NOTICE.
Create new instance of Karas.
You can pass following arguments as hash:
connect_info is an arguments for DBI->connect.
DBI->connect
This is a query builder. You need to pass the child class instance of SQL::Maker.
Default value is : Karas::QueryBuilder->new().
Karas::QueryBuilder->new()
Connect to Database immediately.
If you pass @args, $db->{connec_info} will upgrade by @args.
Reconnect to Database immediately.
Get a database handle. If the connection was closed, Karas reconnects automatically.
Search rows from database. For more details, please see SQL::Maker.
Count rows by $where.
$pager is instance of Data::Page::NoTotalEntries.
Search rows by SQL.
$table_name is optional. Karas finds table name by $sql automatically.
Insert row to database. And refetch row from database.
Insert row to database.
Replace into row to database.
Update row object by \%opts.
Update $table_name set $set where $where.
Delete row object from database.
Delete $table_name where $where.
Refetch $row object from database.
$db->bulk_insert('member', [ +{ name => 'John', email => 'john@example.com' }, +{ name => 'Ben', email => 'ben@example.com' }, ])
This is a bulk insert method. see SQL::Maker::Plugin::InsertMulti.
Clear row class from table name.
Start transaction scope with DBIx::TransactionManager. See DBIx::TransactionManager for more details.
Load plugin and install it. $name is a class name of plugin.
$name
You can use two style of $name. If you want to use plugin under the 'Karas::Plugin::Name' namespace, you just write 'Name' part. If you want to put your plugin on your favorite namespace, you can pass'+My::Own::Plugin' as $name.
$args is a argument for Karas::Plugin::Foo->new($args).
$args
Karas::Plugin::Foo->new($args)
Get a last_insert_id from $dbh.
Karas loads row class from your load path. If you are using Karas class directly, Karas does not loads any row class. But if you use it as a parent class like following:
parent MyDB; use parent qw/Karas/;
Tokuhiro Matsuno <tokuhirom AAJKLFJEF@ GMAIL COM>
Copyright (C) Tokuhiro Matsuno
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Karas, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Karas
CPAN shell
perl -MCPAN -e shell install Karas
For more information on module installation, please visit the detailed CPAN module installation guide.