7 use FreezeThaw qw(freeze thaw cmpStr);
17 FS::dbdef - Database objects
23 $dbdef = new FS::dbdef (@dbdef_table_objects);
24 $dbdef = load FS::dbdef "filename";
26 $dbdef->save("filename");
28 $dbdef->addtable($dbdef_table_object);
30 @table_names = $dbdef->tables;
32 $FS_dbdef_table_object = $dbdef->table;
36 FS::dbdef objects are collections of FS::dbdef_table objects and represnt
37 a database (a collection of tables).
43 =item new TABLE, TABLE, ...
45 Creates a new FS::dbdef object
50 my($proto,@tables)=@_;
51 my(%tables)=map { $_->name, $_ } @tables; #check for duplicates?
53 my($class) = ref($proto) || $proto;
58 bless ($self, $class);
64 Loads an FS::dbdef object from a file.
69 my($proto,$file)=@_; #use $proto ?
70 open(FILE,"<$file") or die "Can't open $file: $!";
71 my($string)=join('',<FILE>); #can $string have newlines? pry not?
72 close FILE or die "Can't close $file: $!";
73 my($self)=thaw $string;
80 Saves an FS::dbdef object to a file.
86 my($string)=freeze $self;
87 open(FILE,">$file") or die "Can't open $file: $!";
89 close FILE or die "Can't close file: $!";
90 my($check_self)=thaw $string;
91 die "Verify error: Can't freeze and thaw dbdef $self"
92 if (cmpStr($self,$check_self));
97 Adds this FS::dbdef_table object.
103 ${$self->{'tables'}}{$table->name}=$table; #check for dupliates?
108 Returns the names of all tables.
114 keys %{$self->{'tables'}};
117 =item table TABLENAME
119 Returns the named FS::dbdef_table object.
125 $self->{'tables'}->{$table};
130 Each FS::dbdef object should have a name which corresponds to its name within
131 the SQL database engine.
135 L<FS::dbdef_table>, L<FS::Record>,