|
NAMESPOPS::Tool::DBI::DiscoverField - SPOPS::ClassFactory rule implementing autofield discoverySYNOPSISmy $config = { myobject => { class => 'My::Object', isa => [ 'SPOPS::DBI' ], field => [], # just for show... rules_from => [ 'My::DiscoverField' ], field_discover => 'yes', base_table => 'mydata', ... }, }; my $class_list = SPOPS::Initialize->process({ config => $config }); # All fields in 'mydata' table now available as object properties DESCRIPTIONSimple behavior rule to dynamically find all fields in a particular database table and set them in our object.Configuration is easy, just put: rules_from => [ 'My::DiscoverField' ], in your object configuration, or add 'My::DiscoverField' to an already-existing 'rules_from' list. Then add: field_discover => 'yes', to your object configuration. Initialize the class and everything in 'field' will be overwritten. GOTCHASThese fields are only discovered once, when the class is created. If you modify the schema of a table (such as with an 'ALTER TABLE' statement while a process (like a webserver) is running with SPOPS definitions the field modifications will not be reflected in the object class definition. (This is actually true of all SPOPS::DBI objects, but probably more apt to pop up here.)COPYRIGHTCopyright (c) 2001-2004 intes.net, inc.. All rights reserved.This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. AUTHORSChris Winters <chris@cwinters.com>
Visit the GSP FreeBSD Man Page Interface. |