NAME

Cake::DBI::Class

DESCRIPTION

Simple Mysql & sqlite Database abstraction layer

SYNOPSIS

use Cake::DBI::Class;

my $sql = Cake::DBI::Class->new(
    'dbi:mysql:table',
    'root',
    'password',
    { RaiseError => 1, AutoCommit => 0 }
);

$sql->table('users');
$sql->find(
    uid => '1'
);

$sql->single;

Methods

new

new constructor - accept list of database connection options, the same as DBI connect

->new(
    'dbi:mysql:table',
    'root',
    'password',
    { RaiseError => 1, AutoCommit => 0 }
);

find

An aliase for search

all

returns all matched records as a list of hash refs

[
    {
        col1 => val1
    },
    {
        col1 => val1
    },
    ...
]

single

fetches first matched record and returns it as a hash ref

{
    col => val
}

first

fetches all matched records and cache them then returns the first record only as a hash ref

{
    col => val
}