The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.


fytwORM - f%#k you thats why ORM, an ORM that doesn't do a lot and doesn't care that you don't like it.


  package Foo;
  our %columns = (
    'foo' => {
        nulls   => 0,
        PK      => 1,
        default => 'default',
        perms   => 'r'
    'bar' => {
        nulls   => 0,
        perms   => 'rw'
    'baz' => {
        nulls   => 0,
        perms   => 'rw',
        FK      => 'Foo::Bar'
  use base 'fytwORM';


This is meant to be a bare minimum ORM used for prototyping / proof of concepts. In other words meant to make concepts quick to develop, and then you can move on to something else. It will provide objects to your tables that can be manipulated and saved back, easy syntax to get out of your way, and really nothing else, you probably won't like it.

fytwORM will not look up the definition of a table on the fly, they need added to the package inheriting from fytwORM. Helper script(s) are provided to create modules for you to use with fytwORM.

fytwORM will not try to figure out if a query is going to work or not. It will send them to the DB and errors will be returned to you courtesy of confess.


new($db_obj, $table)

$db_obj is an object that provides access to your database. It should provide a connect method that returns a DBI object or equivalent. connect will be called each time you call select, insert, etc. so the object should cache its connection, do pooling, whatever.

If $table is not passed, the package inheriting from fytwORM will have its package name split apart and fytwORM will assume that the table name it is supposed to use is the lowercase version of the last part of the name. ex. if you have Foo::Bar::Baz the table name will be baz.

select($args, $opts)

runs a select on the objects table for all the columns in the table. The first result sent back is populated into $self. All the rows are pushed onto an array ref and returned to you.

$args is a hash ref of column => value that will be used in the where clause. Not passing any args results in no where clause.

$opts is a hash ref of options that have various uses. At the moment they are:

  order_by = array of items to order by, used blindly so you can do things like 
  $opts->{'order_by'} = [ "foo", "lower(bar)", "baz desc nulls first" ]

  no_pop = setting to true will cause fytwORM to not populate the object with the return
  of the query, it will still pass the results back to you.
insert($args, $opts)

like select but does an insert

if $args is not passed, the where clause will be "where <PK> = $self->{<PK>}"

update($args, $opts)

like select but does an update

if $args is not passed, the where clause will be "where <PK> = $self->{<PK>}"

delete($args, $opts)

like select but does a delete


Will attempt to save the object back to the DB. If this object was pulled from the DB to begin with, update will be called, if not, then insert is used.

Any arguments passed to save will be passed along to insert or update.


Call with valid SQL. Will set an internal "flag" with the SQL provided, and on the next call to select, insert, update or delete fytwORM will use your SQL instead of what it would normally generate.