Alzabo

 view release on metacpan or  search on metacpan

lib/Alzabo/BackCompat.pm  view on Meta::CPAN

                 \&add_comment_fields,
               ],
               [ 0.71, 0.73,
                 \&convert_pk_to_array,
               ],
               [ 0.79, $Alzabo::VERSION,
                 \&add_table_attributes,
               ],
             );

sub update_schema
{
    my %p = validate( @_, { name    => { type => SCALAR },
                            version => { type => SCALAR },
                          } );

    my @cb;
    foreach my $c (@compat)
    {
        return
            if ( ( $p{version} >= $c->[0] &&

lib/Alzabo/Intro.pod  view on Meta::CPAN


  $movie->delete;

=head2 Validating data

Let's assume that we've been passed a hash of values representing an
update to the location table. Here's a way of making sure that that
this update won't lead to a loop in terms of the parent/child
relationships.

  sub update_location
  {
      my $self = shift; # this is the row object

      my %data = @_;

      if ( $data{parent_location_id} )
      {
          my $parent_location_id = $data{parent_location_id};
          my $location_t = $schema->table('Location');

lib/Alzabo/Intro.pod  view on Meta::CPAN

                  if $location->select('parent_location_id') == $data{location_id};

              $parent_location_id = $location->select('parent_location_id');
          }
      }
  }

Once again, let's rewrite the code to use
L<C<Alzabo::MethodMaker>|Alzabo::MethodMaker>:

  sub update_location
  {
      my $self = shift; # this is the row object

      my %data = @_;

      if ( $data{parent_location_id} )
      {
          my $location = $self;
          while ( my $location = $location->parent )
          {

lib/Alzabo/MethodMaker.pm  view on Meta::CPAN

    $code .= "        \$s->schema->run_in_transaction( sub {\n";
    $code .= "            \$s->pre_update(\\\%p);\n" if $self->{row_class}->can('pre_update');
    $code .= "            \$s->SUPER::update(\%p);\n";
    $code .= "            \$s->post_update(\\\%p);\n" if $self->{row_class}->can('post_update');
    $code .= "        } );\n";

    eval <<"EOF";
{
    package $self->{row_class};

    sub update
    {
        my \$s = shift;
        my \%p = \@_;

$code

    }
}
EOF

lib/Alzabo/Runtime/RowState/InCache.pm  view on Meta::CPAN

        *{__PACKAGE__ . "::$meth"} =
            sub { my $s = shift;

                  $s->refresh(@_) unless $s->_in_cache(@_);

                  $s->$super(@_);
              };
    }
}

sub update
{
    my $class = shift;
    my $row = shift;

    my $old_id = $row->id_as_string;

    $class->refresh($row) unless $class->_in_cache($row);

    my $changed = $class->SUPER::update( $row, @_ );

lib/Alzabo/Runtime/RowState/Live.pm  view on Meta::CPAN

sub select_hash
{
    my $class = shift;
    my $row = shift;

    my @cols = @_ ? @_ : map { $_->name } $row->table->columns;

    return $class->_get_data( $row, @cols );
}

sub update
{
    my $class = shift;
    my $row = shift;
    my %data = @_;

    my $schema = $row->schema;

    my @fk; # this never gets populated unless referential integrity
            # checking is on
    my @set;

lib/Alzabo/Runtime/RowState/Potential.pm  view on Meta::CPAN

{
    my $class = shift;
    my $row = shift;

    my %data;
    @data{@_} = @{ $row->{data} }{@_};

    return %data;
}

sub update
{
    my $class = shift;
    my $row = shift;
    my %data = @_;

    foreach my $k (keys %data)
    {
        # This will throw an exception if the column doesn't exist.
        my $c = $row->table->column($k);

lib/Alzabo/SQLMaker.pm  view on Meta::CPAN

	    ( error => "Cannot mix actual bound values and placeholders in call to values()" );
    }

    $self->{last_op} = 'values';

    return $self;
}

use constant UPDATE_SPEC => { can => 'alias_name' };

sub update
{
    my $self = shift;

    validate_pos( @_, UPDATE_SPEC );

    my $table = shift;

    $self->{sql} = 'UPDATE ';

    $self->{sql} .= ( $self->{quote_identifiers} ?



( run in 0.300 second using v1.01-cache-2.11-cpan-4d4bc49f3ae )