GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  DBIX::DBSCHEMA::COLUMN (3)

.ds Aq ’

NAME

DBIx::DBSchema::Column - Column objects

CONTENTS

SYNOPSIS



  use DBIx::DBSchema::Column;

  #named params with a hashref (preferred)
  $column = new DBIx::DBSchema::Column ( {
    name    => column_name,
    type    => varchar
    null    => NOT NULL,
    length  => 64,
    default => ,
    local   => ,
  } );

  #list
  $column = new DBIx::DBSchema::Column ( $name, $sql_type, $nullability, $length, $default, $local );

  $name = $column->name;
  $column->name( name );

  $sql_type = $column->type;
  $column->type( sql_type );

  $null = $column->null;
  $column->null( NULL );
  $column->null( NOT NULL );
  $column->null(  );

  $length = $column->length;
  $column->length( 10 );
  $column->length( 8,2 );

  $default = $column->default;
  $column->default( Roo );

  $sql_line = $column->line;
  $sql_line = $column->line($datasrc);

  $sql_add_column = $column->sql_add_column;
  $sql_add_column = $column->sql_add_column($datasrc);



DESCRIPTION

DBIx::DBSchema::Column objects represent columns in tables (see DBIx::DBSchema::Table).

METHODS

new HASHREF
new [ name [ , type [ , null [ , length [ , default [ , local ] ] ] ] ] ] Creates a new DBIx::DBSchema::Column object. Takes a hashref of named parameters, or a list. <B>nameB> is the name of the column. <B>typeB> is the SQL data type. <B>nullB> is the nullability of the column (intrepreted using Perl’s rules for truth, with one exception: ‘NOT NULL’ is false). <B>lengthB> is the SQL length of the column. <B>defaultB> is the default value of the column. <B>localB> is reserved for database-specific information.

Note: If you pass a scalar reference as the <B>defaultB> rather than a scalar value, it will be dereferenced and quoting will be forced off. This can be used to pass SQL functions such as now() or explicit empty strings as as defaults.

name [ NAME ] Returns or sets the column name.
type [ TYPE ] Returns or sets the column type.
null [ NULL ] Returns or sets the column null flag (the empty string is equivalent to ‘NOT NULL’)
length [ LENGTH ] Returns or sets the column length.
default [ LOCAL ] Returns or sets the default value.
local [ LOCAL ] Returns or sets the database-specific field.
table_obj [ TABLE_OBJ ] Returns or sets the table object (see DBIx::DBSchema::Table). Typically set internally when a column object is added to a table object.
table_name Returns the table name, or the empty string if this column has not yet been assigned to a table.
line [ DATABASE_HANDLE | DATA_SOURCE [ USERNAME PASSWORD [ ATTR ] ] ] Returns an SQL column definition.

The data source can be specified by passing an open DBI database handle, or by passing the DBI data source name, username and password.

Although the username and password are optional, it is best to call this method with a database handle or data source including a valid username and password - a DBI connection will be opened and the quoting and type mapping will be more reliable.

If passed a DBI data source (or handle) such as ‘DBI:mysql:database’ or ‘DBI:Pg:dbname=database’, will use syntax specific to that database engine. Currently supported databases are MySQL and PostgreSQL. Non-standard syntax for other engines (if applicable) may also be supported in the future.

quoted_default DATABASE_HANDLE Returns this column’s default value quoted for the database.
sql_add_column [ DBH ] Returns SQL to add this column to an existing table. (To create a new table, see sql_create_table in DBIx::DBSchema::Table instead.)

NOTE: This interface has changed in 0.41

Returns two listrefs. The first is a list of column alteration SQL fragments for an ALTER TABLE statement. The second is a list of full SQL statements that should be run after the ALTER TABLE statement.

The data source can be specified by passing an open DBI database handle, or by passing the DBI data source name, username and password.

Although the username and password are optional, it is best to call this method with a database handle or data source including a valid username and password - a DBI connection will be opened and the quoting and type mapping will be more reliable.

If passed a DBI data source (or handle) such as ‘DBI:Pg:dbname=database’, will use PostgreSQL-specific syntax. Non-standard syntax for other engines (if applicable) may also be supported in the future.

sql_alter_column PROTOTYPE_COLUMN [ DATABASE_HANDLE | DATA_SOURCE [ USERNAME PASSWORD [ ATTR ] ] ] Returns SQL to alter this column so that it is identical to the provided prototype column, also a DBIx::DBSchema::Column object.

NOTE: This interface has changed in 0.41

Returns two listrefs. The first is a list of column alteration SQL fragments for an ALTER TABLE statement. The second is a list of full SQL statements that should be run after the ALTER TABLE statement.

Optionally, the data source can be specified by passing an open DBI database handle, or by passing the DBI data source name, username and password.

If passed a DBI data source (or handle) such as ‘DBI:Pg:dbname=database’, will use PostgreSQL-specific syntax. Non-standard syntax for other engines (if applicable) may also be supported in the future.

If not passed a data source (or handle), or if there is no driver for the specified database, will attempt to use generic SQL syntax.

sql_drop_column [ DBH ] Returns SQL to drop this column from an existing table.

NOTE: This interface has changed in 0.41

Returns a list of column alteration SQL fragments for an ALTER TABLE statement.

The optional database handle or DBI data source/username/password is not yet used.

AUTHOR

Ivan Kohler <ivan-dbix-dbschema@420.am>

COPYRIGHT

Copyright (c) 2000-2006 Ivan Kohler Copyright (c) 2007-2013 Freeside Internet Services, Inc. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

BUGS

The new() method should warn that Old-style $class creation without named parameters is deprecated!

Better documentation is needed for sql_add_column

sql_alter_column() has database-specific foo that should be abstracted info DBIx::DBSchema::DBD::Pg

nullify_default option should be documented

SEE ALSO

DBIx::DBSchema::Table, DBIx::DBSchema, DBIx::DBSchema::DBD, DBI
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 DBSCHEMA::COLUMN (3) 2013-10-26

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.