Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

tangram::relational(3pm) [debian man page]

Tangram::Relational(3pm)				User Contributed Perl Documentation				  Tangram::Relational(3pm)

NAME
Tangram::Relational - Orthogonal Object Persistence in Relational Databases SYNOPSIS
use Tangram; $schema = Tangram::Relational->schema( $hashref ); Tangram::Relational->deploy($schema, $dbh); $storage = Tangram::Relational->connect( $schema, $data_source, $username, $password ); $storage->disconnect(); Tangram::Relational->retreat($schema, $dbh); DESCRIPTION
This is the entry point in the vanilla object-relational persistence backend. Vendor-specific backends should be used when they exist. Cur- rently Mysql, Sybase and Oracle have such backends; see Tangram::mysql, Tangram::Sybase and Tangram::Oracle. More backends could be added in the future; they might implement persistence in XML documents, pure object databases, using C database libraries to bypass the need for an RDBMS, etc. CLASS METHODS
schema $schema = Tangram::Relational->schema( $hashref ); Returns a new Schema object. See Tangram::Schema. deploy Tangram::Relational->deploy($schema); Tangram::Relational->deploy($schema, HANDLE); Tangram::Relational->deploy($schema, @dbi_args); Writes SQL statements for preparing a database for use with the given $schema. Called with a single argument, writes SQL statements to STDOUT. Called with two arguments, writes SQL statements to HANDLE. HANDLE may be a DBI connection handle or a file handle. Called with more than two arguments, passes all but the first to DBI::connect() and writes statements to the resulting DBI handle, which is automatically closed. The SQL code is only guaranteed to work on newly created databases. connect $storage = Tangram::Relational->connect( $schema, $data_source, $user, $password, \%options ) Connects to a storage and return a handle object. Dies in case of failure. $schema is a Schema object describing the system of classes stored in the database. $data_source, $user and $password are passed directly to DBI::connect(). \%options is a reference to a hash containing connection options. See Tangram::Storage for a description of available options. retreat Tangram::Relational->retreat($schema); Tangram::Relational->retreat($schema, HANDLE); Tangram::Relational->retreat($schema, @dbi_args); Remove the tables created by deploy(). Only guaranteed to work against a database that was deployed using exactly the same schema. For an explanation of the possible argument lists, see deploy. WRITING A VENDOR DRIVER
Like Charles Moore (inventor of Forth) used to say, "standards are great, everybody should have one!". Tangram can take advantage of extensions available in some SQL dialects. To create a vendor-specific driver, call it "Tangram::Foo" (where "Foo" is the name of the DBI driver, as would be selected with the DBI connection string "dbi:Foo:"), and derive "Tangram::Relational". For now, the existing back-ends should be used as examples of how to extend Tangram to support different databases or utilise some of their more exotic features. perl v5.8.8 2006-03-29 Tangram::Relational(3pm)

Check Out this Related Man Page

Tangram::Expr(3pm)					User Contributed Perl Documentation					Tangram::Expr(3pm)

NAME
Tangram::Expr - represent expressions on database server side SYNOPSIS
my ($r1, $r2) = $storage->remote(qw( ... )); $r1->{field} operator $value $r1->{field} operator $r2->{field2} $r1->{collection}->includes( $obj ) $r1->{collection}->exists( $obj, $filter ) $r1->{collection}->includes_or( $obj1, $obj2, ... ) DESCRIPTION
Tangram::Expr objects represent expressions that will be evaluated on the database server side. Expression objects fall into one of the following categories: numeric, string, reference or collection. Many of the methods in Expr are needed only by people extending Tangram. See also Tangram::Relational, and the source the Tangram::mysql and Tangram::Sybase for examples on how these functions are intercepted to allow RDBMS-specific expressions. NUMERIC EXPRESSIONS
Numeric expression objects can be compared using the operators ==, !=, <, >, <= and >=. The other operand must be either another numeric expression object, or a normal Perl numeric value. The result of the comparison is a Filter. STRING EXPRESSIONS
String expression objects can be compared using the operators eq, ne, lt, gt, le, and ge. The other operand must be either a string expression object or any Perl scalar value. Tangram will automatically quote the operand as required by the SQL syntax. The result of the comparison is a Tangram::Expr::Filter. String expression objects also support the method like($str), where $str is a string that may contain SQL wildcards. The result is a Tan- gram::Expr::Filter that translates to a SQL "LIKE $str" predicate. REFERENCE EXPRESSIONS
Reference expression objects can be compared for equality using operators == and !=. The other operand must be another reference expres- sion, a persistent object or undef(). The result of the comparison is a Filter. COLLECTION EXPRESSIONS
Collection expression objects represents a collection inside an object. It supports the includes() and exists() methods, which returns a Tangram::Expr::Filter stating that the collection must contain the operand. exists() uses a subselect. It also supports the includes_or() methods, which accepts a list and is performs a logical OR - using the IN (x,y,z) SQL construct. The operand may be a Tangram::Remote, a persistent object, or an object ID. operator < is provided as a synonym for includes(). The includes() method can be used for all collection types (Set, Array, Hash, and the Intr* versions). PREDICATES
Predicate objects represent logical expressions, or conditions. Predicates support logical operators &, | and !. Note that a single amper- sand or vertical bar must be used (this is a Perl limitation). The result is another predicate. CLASS METHODS
new($type, $expr, @remotes) Returns a new instance. $type is a Type object corresponding to this expression (see Tangram::Type). $expr is a SQL expression. It will eventually become part of a WHERE-CLAUSE. @remotes contains the Remote objects (see Tangram::Remote) that participate in the expression. Tangram uses this list to insert the corre- sponding tables in the FROM clause and conditions in the WHERE-CLAUSE. INSTANCE METHODS
expr() Returns the SQL equivalent for this expression. type() Returns the Type (see Tangram::Type) corresponding to this expression. objects() Returns the list of the objects that participate in this expression. storage() Returns the Storage associated with this expression. EXAMPLES
$person is called 'Homer' $person->{name} eq 'Homer' $person's name ends with 'mer' $person->{name}->like('%mer'); $person is older than 35 $person->{age} > 35 $person is married to $homer $person->{partner} == $homer $person is not $homer $person != $homer $person is not $homer and is older than 65 $person != $homer & $person->{age} > 65 $person is $bart's parent $person->{children}->includes( $bart ) $person->{children} < $bart $person is not $bart's parent !$person->{children}->includes( $bart ) !($person->{children} < $bart) $person is one of the local list of people, @person $person->in(@person) SEE ALSO
Tangram::Remote, Tangram::Expr, Tangram::Storage perl v5.8.8 2006-03-29 Tangram::Expr(3pm)
Man Page