NAME
DBSimple::Field - describes fields of tables in databases
DESCRIPTION
A DBSimple::Field
object is used to define the fields of a DBSimple::Table
object in terms of its type (a DBSimple::Type
object), the name of the field as far as the database is concerned, and the name of the field as far as the script writer is concerned. (Note that having the two names is intended to free the script writer from artificial restrictions on field names that may be imposed by particular database implementations, as well as to permit the same field name to be used to refer to parallel fields in different databases even if the tables aren't defined the same.)
All references to fields in the DBSimple
suite are mediated through DBSimple::Field
objects. You probably shouldn't need to use this stuff directly at all.
Everything is a method - nothing is exported.
CONSTRUCTORS
- scandef ( [ fieldname, localname, type ] ... )
-
Used by the
DBSimple::Table
constructor to interpret the list of field definitions supplied. Returns a reference to an array ofDBSimple::Field
objects. The fieldname and localname are taken as simple strings, and the type definition is passed on to theDBSimple::Type
package for interpretation.
METHODS
- clone ( )
-
Returns a blessed deep copy of itself. Used by
DBSimple::Table->clone
. - bind ( database )
-
database should be a database implementation class derived from
DBSimple::DB
. This binds the field, so that it knows how to read and write itself. Used byDBSimple::Table->bind
. - fieldname ( )
-
Returns the actual fieldname. Used by database implementation classes when constructing SQL statements.
- localname ( )
-
Returns the local name for the field. Used to discover which field is being referred to when a local fieldname is supplied.
- type ( )
-
Returns the
DBSimple::Type
object that defines the type of this field. - write ( value )
-
Returns the text required to insert the given value into this field. So, for example, strings might need quotes round them and special characters escaped; numbers might need to be in a particular format.
- read ( text )
-
Returns the value represented when the given text comes from this field. This might unescape special characters, etc.
- fielddef ( )
-
Returns the text required to define this field. Typically used to build a SQL 'CREATE' statement.
FUTURE
This bit is all pretty straightforward. Will probably need extra overrides beyond the existing read()
, write()
and fielddef()
options.
HISTORY
v0.02 Hugo 29/3/97
cleaned up some for external release
v0.01 written by Hugo before 15/11/96