use strict; use warnings; package Foo; use base 'Class::DBI'; __PACKAGE__->connection( 'dbi:SQLite:dbname=db_file', '', '' ); __PACKAGE__->table('foo_table'); __PACKAGE__->columns( All => qw/id name/ ); # create table foo_table ( id integer primary key, name char(10) ); 1; package main; use Test::More 'no_plan'; # In test suite. my $cdbi_object = Foo->create( { name => 'Foo' } ); # Check CDBI object is as expected. is $cdbi_object->name, 'Foo', "name is correct (Foo)"; # Change the name through web site. ok( Foo->db_Main->do("update foo_table set name = 'Bar'"), "update name to 'Bar'" ); # undef and reload object. ok my $cdbi_id = $cdbi_object->id, "get id"; $cdbi_object = undef; ok $cdbi_object = Foo->retrieve($cdbi_id), "retrieve object"; # Check that the name has changed. is $cdbi_object->name, 'Bar', "name has changed to 'Bar'"; ok( $_->delete, "delete object" ) for Foo->retrieve_all;