Alzabo
view release on metacpan or search on metacpan
constraints or foreign keys when reverse engineering or making SQL.
There is also no support for large objects (I'm hoping that 7.1 will
be released soon so I won't have to think about this). Otherwise,
the support is about at the same level as MySQL support, though less
mature.
- Added Alzabo::MethodMaker module. This can be used to auto-generate
useful methods for your schema/table/row objects based on the
properties of your objects themselves.
- Reworking/expanding/clarifying/editing of the docs.
- Add order_by and limit options whenever creating a cursor.
- Method documentation POD from the Alzabo::* modules is merged into
the relevant Alzabo::Create::* and Alzabo::Runtime::* modules during
install. This should make it easier to find what you need since the
average user will only need to look at a few modules in
Alzabo::Runtime::*.
- Reworked exceptions so they are all now
lib/Alzabo/Runtime/UniqueRowCache.pm
lib/Alzabo/Schema.pm
lib/Alzabo/SQLMaker.pm
lib/Alzabo/SQLMaker/MySQL.pm
lib/Alzabo/SQLMaker/PostgreSQL.pm
lib/Alzabo/Table.pm
lib/Alzabo/Utils.pm
LICENSE
Makefile.PL
MANIFEST This list of files
mason/widgets/edit_field_checkbox
mason/widgets/edit_field_text_input
mason/widgets/edit_field_textarea
mason/widgets/fk_to_one_select
mason/widgets/insert
mason/widgets/insert_or_update
mason/widgets/update
META.yml
README
t/01-compile.t
t/01-driver.t
t/02-create.t
t/03-runtime.t
SHA1 df04b6491aa096118da455e432cc8d08cd167073 lib/Alzabo/Runtime/RowState/Potential.pm
SHA1 841736c73615982bf5a1cbd0ba5838b9df55a19f lib/Alzabo/Runtime/Schema.pm
SHA1 b6ee46102a3b367772b48431e1def689283e3902 lib/Alzabo/Runtime/Table.pm
SHA1 9286403266901d80a226476bb43cf0c1f10826b1 lib/Alzabo/Runtime/UniqueRowCache.pm
SHA1 ce71db21e316956a7a2cd98824c0a7d18dc1ab83 lib/Alzabo/SQLMaker.pm
SHA1 2bc532caa834986aa22ab277454f9231d2066731 lib/Alzabo/SQLMaker/MySQL.pm
SHA1 7ada47ae40a0606442200d4cfd9640f846f44c23 lib/Alzabo/SQLMaker/PostgreSQL.pm
SHA1 ac979e736d929e412e119e8271eeb3693046acfa lib/Alzabo/Schema.pm
SHA1 9f63a5bdc1342935eb5a78e2eec25b76ae05b923 lib/Alzabo/Table.pm
SHA1 8b97a915e10af7ac222b88107286a5d577f43e81 lib/Alzabo/Utils.pm
SHA1 f847fb97ccb893a2d49081016b4d26837d7e118a mason/widgets/edit_field_checkbox
SHA1 1ec65e465abc63eef84dbd78b6b26b53de69c230 mason/widgets/edit_field_text_input
SHA1 2a39cb0dacfa7c5bd3f4b0192e2034125283d9fb mason/widgets/edit_field_textarea
SHA1 a7a0e78c774733204a23ac2ba71e7faf6433ce7e mason/widgets/fk_to_one_select
SHA1 6c5c2cbe53d95d8a38d7164f0351bcb808ea677c mason/widgets/insert
SHA1 316becaea6da6008a0aa54350344e22f47ddb1c5 mason/widgets/insert_or_update
SHA1 ef79ea559a1a6cb262d5245cfa596fbf28a18986 mason/widgets/update
SHA1 eff25867aade830f62008e9c5ab0479ed30b8d69 t/01-compile.t
SHA1 94036f06e5f7a955326e8da71488f01c53b1f215 t/01-driver.t
SHA1 313c1ce15ce1b3720d5704ffbd823a43e0f5e833 t/02-create.t
SHA1 7eec7b4cd0bdccecf807ae241def67a1970f2a20 t/03-runtime.t
SHA1 0a68944ae8d4231f82b9873bc34436e41f7ec909 t/04-rev-engineer.t
SHA1 d22a8f365a9cc9853d7f690a62660c0892940b6e t/05a-rules-mysql.t
lib/Alzabo/Intro.pod view on Meta::CPAN
TABLE: Person
person_id tinyint -- primary key
name varchar(200)
birthdate date
birthplace_location_id tinyint -- foreign key to location
TABLE: Job
job_id tinyint -- primary key
job varchar(200) -- something like 'actor' or 'director'
TABLE: Credit
movie_id tinyint -- primary key part 1, foreign key to movie
person_id tinyint -- primary key part 2, foreign key to person
job_id tinyint -- primary key part 3, foreign key to job
TABLE: Location
location_id tinyint -- primary key
location varchar(200) -- 'New York City' or 'USA'
parent_location_id tinyint -- foreign key to location
=head2 Fetching data
lib/Alzabo/Intro.pod view on Meta::CPAN
and is done for similar reasons.
First of all, let's do something simple. Let's assume I have a
person_id value and I want to find all the movies that they were in
and print the title, year of release, and the job they did in the
movie. Here's what it looks like:
my $schema = Alzabo::Runtime::Schema->load_from_file( name => 'movies' );
my $person_t = $schema->table('Person');
my $credit_t = $schema->table('Credit');
my $movie_t = $schema->table('Movie');
my $job_t = $schema->table('Job');
# returns a row representing this person.
my $person = $person_t->row_by_pk( pk => 42 );
# all the rows in the credit table that have the person_id of 42.
my $cursor =
$person->rows_by_foreign_key
( foreign_key =>
$person_t->foreign_keys_by_table($credit_t) );
print $person->select('name'), " was in the following films:\n\n";
while (my $credit = $cursor->next)
{
# rows_by_foreign_key returns a RowCursor object. We immediately
# call its next method, knowing it will only have one row (if
# it doesn't then our referential integrity is in trouble!)
my $movie =
$credit->rows_by_foreign_key
( foreign_key =>
$credit_t->foreign_keys_by_table($movie_t) )->next;
my $job =
$credit->rows_by_foreign_key
( foreign_key =>
$credit_t->foreign_keys_by_table($job_t) )->next;
print $movie->select('title'), " released in ", $movie->select('release_year'), "\n";
print ' ', $job->('job'), "\n";
}
A more sophisticated version of this code would take into account that
a person can do more than one job in the same movie.
The method names are quite verbose, so let's redo the example using
L<C<Alzabo::MethodMaker>|Alzabo::MethodMaker>:
lib/Alzabo/Intro.pod view on Meta::CPAN
# would expect.
use Alzabo::MethodMaker( schema => 'movies',
all => 1,
name_maker => \&method_namer );
my $schema = Alzabo::Runtime::Schema->load_from_file( name => 'movies' );
# instantiates a row representing this person.
my $person = $schema->Person->row_by_pk( pk => 42 );
# all the rows in the credit table that have the person_id of 42.
my $cursor = $person->Credits;
print $person->name, " was in the following films:\n\n";
while (my $credit = $cursor->next)
{
my $movie = $credit->Movie;
my $job = $credit->Job;
print $movie->title, " released in ", $movie->release_year, "\n";
print ' ', $job->job, "\n";
}
=head2 Updating data
Updates are done by calling the C<update()> method on a row object:
$movie->update( title => 'Chungking Express',
lib/Alzabo/MethodMaker.pm view on Meta::CPAN
=item * foreign_keys => $bool
Creates methods in row objects named for the table to which the
relationship exists. These methods return either a single
L<C<Alzabo::Runtime::Row>|Alzabo::Runtime::Row> object or a single
L<C<Alzabo::Runtime::RowCursor>|Alzabo::Runtime::RowCursor> object,
depending on the cardinality of the relationship.
For exa
Movie Credit
--------- --------
movie_id movie_id
title person_id
role_name
This would create a method for Movie row objects called C<Credit()>
which would return a cursor for the associated Credit table rows.
Similarly, Credit row objects would have a method called C<Movie()>
which would return the associated Movie row object.
=item * linking_tables => $bool
A linking table, as defined here, is a table with a two column primary
key, with each column being a foreign key to another table's primary
key. These tables exist to facilitate n..n logical relationships. If
both C<foreign_keys> and C<linking_tables> are true, then methods will
be created that skip the intermediate linking tables.
lib/Alzabo/Runtime/Table.pm view on Meta::CPAN
=for pod_merge attributes
=for pod_merge has_attribute
=for pod_merge comment
=head1 LAZY COLUMN LOADING
This concept was taken directly from Michael Schwern's Class::DBI
module (credit where it is due).
By default, L<C<Alzabo::Runtime::Row>|Alzabo::Runtime::Row> objects
load all data from the database except blob type columns (columns with
an unbounded length). This data is stored internally in the object
after being fetched.
If you want to change what data is prefetched, there are two methods
you can use.
The first method,
mason/widgets/edit_field_checkbox view on Meta::CPAN
<%doc>
=pod
=head1 NAME
edit_field_checkbox
=head1 SYNOPSIS
<& edit_field_checkbox, column => $column, row => $row &>
=head1 DESCRIPTION
Given a column and an optional row, this component produces a checkbox
form element for that column. The value of this column when checked
is 1.
If a row is given, then its value will determine whether or not the
checkbox is checked. Otherwise the column's default value will be
used.
mason/widgets/edit_field_text_input view on Meta::CPAN
<%doc>
=pod
=head1 NAME
edit_field_text_input
=head1 SYNOPSIS
<& edit_field_text_input, column => $column, row => $row &>
=head1 DESCRIPTION
Given a column and an optional row, this component produces a text
input form element for that column.
If a row is given, then its value will be used as the default value
for the form element.
=head1 PARAMETERS
mason/widgets/edit_field_textarea view on Meta::CPAN
<%doc>
=pod
=head1 NAME
edit_field_textarea
=head1 SYNOPSIS
<& edit_field_textarea, column => $column, row => $row &>
=head1 DESCRIPTION
Given a column and an optional row, this component produces a textarea
form element for that column.
If a row is given, then its value will be used as the default value
for the form element.
=head1 PARAMETERS
( run in 0.595 second using v1.01-cache-2.11-cpan-de7293f3b23 )