| DBIx-DBSchema documentation | Contained in the DBIx-DBSchema distribution. |
DBIx::DBSchema::ColGroup - Column group objects
use DBIx::DBSchema::ColGroup;
$colgroup = new DBIx::DBSchema::ColGroup ( $lol_ref );
$colgroup = new DBIx::DBSchema::ColGroup ( \@lol );
$colgroup = new DBIx::DBSchema::ColGroup (
[
[ 'single_column' ],
[ 'multiple_columns', 'another_column', ],
]
);
$lol_ref = $colgroup->lol_ref;
@sql_lists = $colgroup->sql_list;
@singles = $colgroup->singles;
This class is deprecated and included for backwards-compatibility only. See DBIx::DBSchema::Index for the current class used to store unique and non-unique indices.
DBIx::DBSchema::ColGroup objects represent sets of sets of columns. (IOW a "list of lists" - see perllol.)
Creates a new DBIx::DBSchema::ColGroup object. Pass a reference to a list of lists of column names.
Returns a reference to a list of lists of column names.
Returns a flat list of comma-separated values, for SQL statements.
For example:
@lol = (
[ 'single_column' ],
[ 'multiple_columns', 'another_column', ],
);
$colgroup = new DBIx::DBSchema::ColGroup ( \@lol );
print join("\n", $colgroup->sql_list), "\n";
Will print:
single_column multiple_columns, another_column
Returns a flat list of all single item lists.
Ivan Kohler <ivan-dbix-dbschema@420.am>
Copyright (c) 2000 Ivan Kohler Copyright (c) 2000 Mail Abuse Prevention System LLC All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| DBIx-DBSchema documentation | Contained in the DBIx-DBSchema distribution. |
package DBIx::DBSchema::ColGroup; use strict; use Carp;
sub new { my($proto, $lol) = @_; my $class = ref($proto) || $proto; carp "WARNING: $proto is deprecated; switch to DBIx::DBSchema::Index"; my $self = { 'lol' => $lol, }; bless ($self, $class); }
sub lol_ref { my($self) = @_; $self->{'lol'}; }
sub sql_list { #returns a flat list of comman-separates lists (for sql) my($self)=@_; grep $_ ne '', map join(', ', @{$_}), @{$self->{'lol'}}; }
sub singles { #returns single-field groups as a flat list my($self)=@_; #map ${$_}[0], grep scalar(@{$_}) == 1, @{$self->{'lol'}}; map { ${$_}[0] =~ /^(\w+)$/ #aah! or die "Illegal column ", ${$_}[0], " in colgroup!"; $1; } grep scalar(@{$_}) == 1, @{$self->{'lol'}}; }
1;