Rob Giseburt > CGI-AppToolkit > CGI::AppToolkit::Data::TestSQLObject

Download:
CGI-AppToolkit-0.051.tgz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.05   Source  

NAME ^

CGI::AppToolkit::Data::TestSQLObject - An example object, illustrating how to subclass CGI::AppToolkit::Data::SQLObject.

SYNOPSIS ^

  package CGI::AppToolkit::Data::TestSQLObject;

  use base 'CGI::AppToolkit::Data::SQLObject';
  use strict;
  
  #-------------------------------------#
  
  # initialize variables
  sub init {
    my $self = shift;
    
    $self->set_table('test_shebang');
    $self->set_index('id');
    $self->set_all_insert_columns([qw/address zip password active verified html/]);
    $self->set_default_insert_columns({'start' => 'now()'});
    $self->set_all_update_columns($self->get_all_insert_columns);
    
    1;
  }
    
  #-------------------------------------#
  
  # get a prepared db statement
  sub get_db_statement_local {
    my $self = shift;
    my $name = shift;
    
    my $db = $self->get_kit->get_dbi();
    
    if ($name eq 'now') {
      return [$db->prepare('select CURRENT_DATE as now'), []];
    } elsif ($name eq 'date/<1') {
      return [$db->prepare('select * from people where birthday < ?'), [qw/date/]];
    }
    
    undef
  }
  
  1;
syntax highlighting: