Skip to content

Instantly share code, notes, and snippets.

@issm
Forked from clairvy/a.pl
Created September 8, 2010 13:18
Show Gist options
  • Save issm/570117 to your computer and use it in GitHub Desktop.
Save issm/570117 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use strict;
use warnings;
use FindBin;
use lib qq($FindBin::Bin/lib);
use Data::Dumper;
# preapare table
# $ sqlite3 user.db 'CREATE TABLE user (id INTEGER PRIMARY KEY AUTOINCREMENT, nickname, t_mod, user_id);'
# $ sqlite3 user.db 'INSERT INTO user (nickname, user_id) VALUES ("issm", 100);'
# preapare table
# $ mysql -e "CREATE TABLE user (nickname TEXT, t_mod TIMESTAMP, user_id INT)" test
# $ mysql -e 'INSERT user (nickname, user_id) VALUES ("issm", 100)' test
package Your::Model;
use DBIx::Skinny setup => {
# dsn => 'dbi:SQLite:dbname=user.db',
dsn => 'DBI:mysql:database=test',
username => '',
password => '',
};
1;
package Your::Model::Schema;
use DBIx::Skinny::Schema;
install_table user => schema {
pk 'id';
columns qw/
id
nickname
user_id
/;
};
1;
package main;
my $row = Your::Model->new;
print Data::Dumper->Dump([\$row]);
$row->update(
'user',
{nickname => 'issm', t_mod => time()},
{user_idx => 9}, # ワザとミス.ホントは user_id
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment