MATSUNO★Tokuhiro > Karas-0.07 > Karas::Row

Download:
Karas-0.07.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Source  

NAME ^

Karas::Row - row class for Karas

SYNOPSIS ^

    # Here is a synopsis. But you don't need to write this class by your hand.
    # Karas::Dumper can generate this class by your RDBMS schema, automatically.
    package My::Row::Member;
    use parent qw/Karas::Row/;

    sub table_name { 'member' }
    sub primary_key { qw/id/ }
    sub column_names { qw/id name email/ }

    __PACKAGE__->mk_column_accessors(column_names());

    1;

DESCRIPTION ^

This is Row class for Karas.

METHODS ^

my @pk = $row->primary_key()

This method returns list of strings. It's primary keys.

Default method returns 'id'. You can override this method to use another primary key.

my $table_name = $row->table_name()

Returns table name. It's set at constructor.

my $val = $row->get_column($column_name)

Get a column value from row object. This method throws exception if column is not selected by SQL.

$row->set_column($column_name, $value:Str)

Set a column value for row object.

You can't set ScalarRef. If you want to use $row->set_column('cnt' => \'cnt+1') form, you should use $db->update($row, { cnt => \'cnt+1'}) instead.

__PACKAGE__->mk_column_accessors(@column_names)

Create column accessor methods by @column_names.

syntax highlighting: