.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "Data::ObjectDriver::BaseObject 3pm" .TH Data::ObjectDriver::BaseObject 3pm "2023-02-05" "perl v5.36.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Data::ObjectDriver::BaseObject \- base class for modeled objects .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& package Ingredient; \& use base qw( Data::ObjectDriver::BaseObject ); \& \& _\|_PACKAGE_\|_\->install_properties({ \& columns => [ \*(Aqingredient_id\*(Aq, \*(Aqrecipe_id\*(Aq, \*(Aqname\*(Aq, \*(Aqquantity\*(Aq ], \& datasource => \*(Aqingredient\*(Aq, \& primary_key => [ \*(Aqrecipe_id\*(Aq, \*(Aqingredient_id\*(Aq ], \& driver => FoodDriver\->driver, \& }); \& \& _\|_PACKAGE_\|_\->has_a( \& { class => \*(AqRecipe\*(Aq, column => \*(Aqrecipe_id\*(Aq, } \& ); \& \& package main; \& \& my ($ingredient) = Ingredient\->search({ recipe_id => 4, name => \*(Aqrutabaga\*(Aq }); \& $ingredient\->quantity(7); \& $ingredient\->save(); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fIData::ObjectDriver::BaseObject\fR provides services to data objects modeled with the \fIData::ObjectDriver\fR object relational mapper. .SH "CLASS DEFINITION" .IX Header "CLASS DEFINITION" .ie n .SS """Class\->install_properties(\e%params)""" .el .SS "\f(CWClass\->install_properties(\e%params)\fP" .IX Subsection "Class->install_properties(%params)" Defines all the properties of the specified object class. Generally you should call \f(CW\*(C`install_properties()\*(C'\fR in the body of your class definition, so the properties can be set when the class is \f(CW\*(C`use\*(C'\fRd or \f(CW\*(C`require\*(C'\fRd. .PP Required members of \f(CW%params\fR are: .IP "\(bu" 4 \&\f(CW\*(C`columns\*(C'\fR .Sp All the columns in the object class. This property is an arrayref. .IP "\(bu" 4 \&\f(CW\*(C`datasource\*(C'\fR .Sp The identifier of the table in which the object class's data are stored. Usually the datasource is simply the table name, but the datasource can be decorated into the table name by the \f(CW\*(C`Data::ObjectDriver::DBD\*(C'\fR module if the database requires special formatting of table names. .IP "\(bu" 4 \&\f(CW\*(C`driver\*(C'\fR or \f(CW\*(C`get_driver\*(C'\fR .Sp The driver used to perform database operations (lookup, update, etc) for the object class. .Sp \&\f(CW\*(C`driver\*(C'\fR is the instance of \f(CW\*(C`Data::ObjectDriver\*(C'\fR to use. If your driver requires configuration options not available when the properties are initially set, specify a coderef as \f(CW\*(C`get_driver\*(C'\fR instead. It will be called the first time the driver is needed, storing the driver in the class's \f(CW\*(C`driver\*(C'\fR property for subsequent calls. .PP The optional members of \f(CW%params\fR are: .IP "\(bu" 4 \&\f(CW\*(C`primary_key\*(C'\fR .Sp The column or columns used to uniquely identify an instance of the object class. If one column (such as a simple numeric \s-1ID\s0) identifies the class, \&\f(CW\*(C`primary_key\*(C'\fR should be a scalar. Otherwise, \f(CW\*(C`primary_key\*(C'\fR is an arrayref. .IP "\(bu" 4 \&\f(CW\*(C`column_defs\*(C'\fR .Sp Specifies types for specially typed columns, if any, as a hashref. For example, if a column holds a timestamp, name it in \f(CW\*(C`column_defs\*(C'\fR as a \f(CW\*(C`date\*(C'\fR for proper handling with some \f(CW\*(C`Data::ObjectDriver::Driver::DBD\*(C'\fR database drivers. Columns for which types aren't specified are handled as \f(CW\*(C`char\*(C'\fR columns. .Sp Known \f(CW\*(C`column_defs\*(C'\fR types are: .RS 4 .IP "\(bu" 4 \&\f(CW\*(C`blob\*(C'\fR .Sp A blob of binary data. \f(CW\*(C`Data::ObjectDriver::Driver::DBD::Pg\*(C'\fR maps this to \&\f(CW\*(C`DBI::Pg::PG_BYTEA\*(C'\fR, \f(CW\*(C`DBD::SQLite\*(C'\fR to \f(CW\*(C`DBI::SQL_BLOB\*(C'\fR and \f(CW\*(C`DBD::Oracle\*(C'\fR to \f(CW\*(C`ORA_BLOB\*(C'\fR. .IP "\(bu" 4 \&\f(CW\*(C`bin_char\*(C'\fR .Sp A non-blob string of binary data. \f(CW\*(C`Data::ObjectDriver::Driver::DBD::SQLite\*(C'\fR maps this to \f(CW\*(C`DBI::SQL_BINARY\*(C'\fR. .RE .RS 4 .Sp Other types may be defined by custom database drivers as needed, so consult their documentation. .RE .IP "\(bu" 4 \&\f(CW\*(C`db\*(C'\fR .Sp The name of the database. When used with \f(CW\*(C`Data::ObjectDriver::Driver::DBI\*(C'\fR type object drivers, this name is passed to the \f(CW\*(C`init_db\*(C'\fR method when the actual database handle is being created. .PP Custom object drivers may define other properties for your object classes. Consult the documentation of those object drivers for more information. .ie n .SS """Class\->install_column($col, $def)""" .el .SS "\f(CWClass\->install_column($col, $def)\fP" .IX Subsection "Class->install_column($col, $def)" Modify the Class definition to declare a new column \f(CW$col\fR of definition <$def> (see column_defs). .ie n .SS """Class\->has_a(@definitions)""" .el .SS "\f(CWClass\->has_a(@definitions)\fP" .IX Subsection "Class->has_a(@definitions)" \&\fB\s-1NOTE:\s0\fR \f(CW\*(C`has_a\*(C'\fR is an experimental system, likely to both be buggy and change in future versions. .PP Defines a foreign key reference between two classes, creating accessor methods to retrieve objects both ways across the reference. For each defined reference, two methods are created: one for objects of class \f(CW\*(C`Class\*(C'\fR to load the objects they reference, and one for objects of the referenced class to load the set of \&\f(CW\*(C`Class\*(C'\fR objects that reference \fIthem\fR. .PP For example, this definition: .PP .Vb 4 \& package Ingredient; \& _\|_PACKAGE_\|_\->has_a( \& { class => \*(AqRecipe\*(Aq, column => \*(Aqrecipe_id\*(Aq }, \& ); .Ve .PP would create \f(CW\*(C`Ingredient\->recipe_obj\*(C'\fR and \f(CW\*(C`Recipe\->ingredient_objs\*(C'\fR instance methods. .PP Each member of \f(CW@definitions\fR is a hashref containing the parameters for creating one accessor method. The required members of these hashes are: .IP "\(bu" 4 \&\f(CW\*(C`class\*(C'\fR .Sp The class to associate. .IP "\(bu" 4 \&\f(CW\*(C`column\*(C'\fR .Sp The column or columns in this class that identify the primary key of the associated object. As with primary keys, use a single scalar string for a single column or an arrayref for a composite key. .PP The optional members of \f(CW\*(C`has_a()\*(C'\fR definitions are: .IP "\(bu" 4 \&\f(CW\*(C`method\*(C'\fR .Sp The name of the accessor method to create. .Sp By default, the method name is the concatenated set of column names with each \&\f(CW\*(C`_id\*(C'\fR suffix removed, and the suffix \f(CW\*(C`_obj\*(C'\fR appended at the end of the method name. For example, if \f(CW\*(C`column\*(C'\fR were \f(CW\*(C`[\*(Aqrecipe_id\*(Aq, \*(Aqingredient_id\*(Aq]\*(C'\fR, the resulting method would be called \f(CW\*(C`recipe_ingredient_obj\*(C'\fR by default. .IP "\(bu" 4 \&\f(CW\*(C`cached\*(C'\fR .Sp Whether to keep a reference to the foreign object once it's loaded. Subsequent calls to the accessor method would return that reference immediately. .IP "\(bu" 4 \&\f(CW\*(C`parent_method\*(C'\fR .Sp The name of the reciprocal method created in the referenced class named in \&\f(CW\*(C`class\*(C'\fR. .Sp By default, that method is named with the lowercased name of the current class with the suffix \f(CW\*(C`_objs\*(C'\fR. For example, if in your \f(CW\*(C`Ingredient\*(C'\fR class you defined a relationship with \f(CW\*(C`Recipe\*(C'\fR on the column \f(CW\*(C`recipe_id\*(C'\fR, this would create a \f(CW\*(C`$recipe\->ingredient_objs\*(C'\fR method. .Sp Note that if you reference one class with multiple sets of fields, you can omit only one parent_method; otherwise the methods would be named the same thing. For instance, if you had a \f(CW\*(C`Friend\*(C'\fR class with two references to \f(CW\*(C`User\*(C'\fR objects in its \f(CW\*(C`user_id\*(C'\fR and \f(CW\*(C`friend_id\*(C'\fR columns, one of them would need a \&\f(CW\*(C`parent_method\*(C'\fR. .ie n .SS """Class\->has_partitions(%param)""" .el .SS "\f(CWClass\->has_partitions(%param)\fP" .IX Subsection "Class->has_partitions(%param)" Defines that the given class is partitioned, configuring it for use with the \&\f(CW\*(C`Data::ObjectDriver::Driver::SimplePartition\*(C'\fR object driver. Required members of \f(CW%param\fR are: .IP "\(bu" 4 \&\f(CW\*(C`number\*(C'\fR .Sp The number of partitions in which objects of this class may be stored. .IP "\(bu" 4 \&\f(CW\*(C`get_driver\*(C'\fR .Sp A function that returns an object driver, given a partition \s-1ID\s0 and any extra parameters specified when the class's \&\f(CW\*(C`Data::ObjectDriver::Driver::SimplePartition\*(C'\fR was instantiated. .PP Note that only the parent object for use with the \f(CW\*(C`SimplePartition\*(C'\fR driver should use \f(CW\*(C`has_partitions()\*(C'\fR. See \&\f(CW\*(C`Data::ObjectDriver::Driver::SimplePartition\*(C'\fR for more about partitioning. .SH "BASIC USAGE" .IX Header "BASIC USAGE" .ie n .SS """Class\->lookup($id)""" .el .SS "\f(CWClass\->lookup($id)\fP" .IX Subsection "Class->lookup($id)" Returns the instance of \f(CW\*(C`Class\*(C'\fR with the given value for its primary key. If \&\f(CW\*(C`Class\*(C'\fR has a complex primary key (more than one column), \f(CW$id\fR should be an arrayref specifying the column values in the same order as specified in the \&\f(CW\*(C`primary_key\*(C'\fR property. .ie n .SS """Class\->search(\e%terms, [\e%args])""" .el .SS "\f(CWClass\->search(\e%terms, [\e%args])\fP" .IX Subsection "Class->search(%terms, [%args])" Returns all instances of \f(CW\*(C`Class\*(C'\fR that match the values specified in \&\f(CW\*(C`\e%terms\*(C'\fR, keyed on column names. In list context, \f(CW\*(C`search\*(C'\fR returns the objects containing those values. In scalar context, \f(CW\*(C`search\*(C'\fR returns an iterator function containing the same set of objects. .PP Your search can be customized with parameters specified in \f(CW\*(C`\e%args\*(C'\fR. Commonly recognized parameters (those implemented by the standard \f(CW\*(C`Data::ObjectDriver\*(C'\fR object drivers) are: .IP "\(bu" 4 \&\f(CW\*(C`sort\*(C'\fR .Sp A column by which to order the object results. .IP "\(bu" 4 \&\f(CW\*(C`direction\*(C'\fR .Sp If set to \f(CW\*(C`descend\*(C'\fR, the results (ordered by the \f(CW\*(C`sort\*(C'\fR column) are returned in descending order. Otherwise, results will be in ascending order. .IP "\(bu" 4 \&\f(CW\*(C`limit\*(C'\fR .Sp The number of results to return, at most. You can use this with \f(CW\*(C`offset\*(C'\fR to paginate your \f(CW\*(C`search()\*(C'\fR results. .IP "\(bu" 4 \&\f(CW\*(C`offset\*(C'\fR .Sp The number of results to skip before the first returned result. Use this with \&\f(CW\*(C`limit\*(C'\fR to paginate your \f(CW\*(C`search()\*(C'\fR results. .IP "\(bu" 4 \&\f(CW\*(C`fetchonly\*(C'\fR .Sp A list (arrayref) of columns that should be requested. If specified, only the specified columns of the resulting objects are guaranteed to be set to the correct values. .Sp Note that any caching object drivers you use may opt to ignore \f(CW\*(C`fetchonly\*(C'\fR instructions, or decline to cache objects queried with \f(CW\*(C`fetchonly\*(C'\fR. .IP "\(bu" 4 \&\f(CW\*(C`for_update\*(C'\fR .Sp If true, instructs the object driver to indicate the query is a search, but the application may want to update the data after. That is, the generated \s-1SQL\s0 \&\f(CW\*(C`SELECT\*(C'\fR query will include a \f(CW\*(C`FOR UPDATE\*(C'\fR clause. .PP All options are passed to the object driver, so your driver may support additional options. .ie n .SS """Class\->result(\e%terms, [\e%args])""" .el .SS "\f(CWClass\->result(\e%terms, [\e%args])\fP" .IX Subsection "Class->result(%terms, [%args])" Takes the same \fI\f(CI%terms\fI\fR and \fI\f(CI%args\fI\fR arguments that \fIsearch\fR takes, but instead of executing the query immediately, returns a \&\fIData::ObjectDriver::ResultSet\fR object representing the set of results. .ie n .SS """$obj\->exists()""" .el .SS "\f(CW$obj\->exists()\fP" .IX Subsection "$obj->exists()" Returns true if \f(CW$obj\fR already exists in the database. .ie n .SS """$obj\->save()""" .el .SS "\f(CW$obj\->save()\fP" .IX Subsection "$obj->save()" Saves \f(CW$obj\fR to the database, whether it is already there or not. That is, \&\f(CW\*(C`save()\*(C'\fR is functionally: .PP .Vb 1 \& $obj\->exists() ? $obj\->update() : $obj\->insert() .Ve .ie n .SS """$obj\->update()""" .el .SS "\f(CW$obj\->update()\fP" .IX Subsection "$obj->update()" Saves changes to \f(CW$obj\fR, an object that already exists in its database. .ie n .SS """$obj\->insert()""" .el .SS "\f(CW$obj\->insert()\fP" .IX Subsection "$obj->insert()" Adds \f(CW$obj\fR to the database in which it should exist, according to its object driver and configuration. .ie n .SS """$obj\->remove()""" .el .SS "\f(CW$obj\->remove()\fP" .IX Subsection "$obj->remove()" Deletes \f(CW$obj\fR from its database. .ie n .SS """$obj\->replace()""" .el .SS "\f(CW$obj\->replace()\fP" .IX Subsection "$obj->replace()" Replaces \f(CW$obj\fR in the database. Does the right thing if the driver knows how to \s-1REPLACE\s0 object, ala MySQL. .SH "USAGE" .IX Header "USAGE" .ie n .SS """Class\->new(%columns)""" .el .SS "\f(CWClass\->new(%columns)\fP" .IX Subsection "Class->new(%columns)" Returns a new object of the given class, initializing its columns with the values in \f(CW%columns\fR. .ie n .SS """$obj\->init(%columns)""" .el .SS "\f(CW$obj\->init(%columns)\fP" .IX Subsection "$obj->init(%columns)" Initializes \f(CW$obj\fRi by initializing its columns with the values in \&\f(CW%columns\fR. .PP Override this method if you must do initial configuration to new instances of \&\f(CW$obj\fR's class that are not more appropriate as a \f(CW\*(C`post_load\*(C'\fR callback. .ie n .SS """Class\->properties()""" .el .SS "\f(CWClass\->properties()\fP" .IX Subsection "Class->properties()" Returns the named object class's properties as a hashref. Note that some of the standard object class properties, such as \f(CW\*(C`primary_key\*(C'\fR, have more convenient accessors than reading the properties directly. .ie n .SS """Class\->driver()""" .el .SS "\f(CWClass\->driver()\fP" .IX Subsection "Class->driver()" Returns the object driver for this class, invoking the class's \fIget_driver\fR function (and caching the result for future calls) if necessary. .ie n .SS """Class\->get_driver($get_driver_fn)""" .el .SS "\f(CWClass\->get_driver($get_driver_fn)\fP" .IX Subsection "Class->get_driver($get_driver_fn)" Sets the function used to find the object driver for \fIClass\fR objects (that is, the \f(CW\*(C`get_driver\*(C'\fR property). .PP Note that once \f(CW\*(C`driver()\*(C'\fR has been called, the \f(CW\*(C`get_driver\*(C'\fR function is not used. Usually you would specify your function as the \f(CW\*(C`get_driver\*(C'\fR parameter to \&\f(CW\*(C`install_properties()\*(C'\fR. .ie n .SS """Class\->is_pkless()""" .el .SS "\f(CWClass\->is_pkless()\fP" .IX Subsection "Class->is_pkless()" Returns whether the given object class has a primary key defined. .ie n .SS """Class\->is_primary_key($column)""" .el .SS "\f(CWClass\->is_primary_key($column)\fP" .IX Subsection "Class->is_primary_key($column)" Returns whether the given column is or is part of the primary key for \f(CW\*(C`Class\*(C'\fR objects. .ie n .SS """$obj\->primary_key()""" .el .SS "\f(CW$obj\->primary_key()\fP" .IX Subsection "$obj->primary_key()" Returns the \fIvalues\fR of the primary key fields of \f(CW$obj\fR. .ie n .SS """Class\->primary_key_tuple()""" .el .SS "\f(CWClass\->primary_key_tuple()\fP" .IX Subsection "Class->primary_key_tuple()" Returns the \fInames\fR of the primary key fields of \f(CW\*(C`Class\*(C'\fR objects. .ie n .SS """$obj\->is_same($other_obj)""" .el .SS "\f(CW$obj\->is_same($other_obj)\fP" .IX Subsection "$obj->is_same($other_obj)" Do a primary key check on \f(CW$obj\fR and $ and returns true only if they are identical. .ie n .SS """$obj\->object_is_stored()""" .el .SS "\f(CW$obj\->object_is_stored()\fP" .IX Subsection "$obj->object_is_stored()" Returns true if the object hasn't been stored in the database yet. This is particularly useful in triggers where you can then determine if the object is being \s-1INSERTED\s0 or just \s-1UPDATED.\s0 .ie n .SS """$obj\->pk_str()""" .el .SS "\f(CW$obj\->pk_str()\fP" .IX Subsection "$obj->pk_str()" returns the primary key has a printable string. .ie n .SS """$obj\->has_primary_key()""" .el .SS "\f(CW$obj\->has_primary_key()\fP" .IX Subsection "$obj->has_primary_key()" Returns whether the given object has values for all of its primary key fields. .ie n .SS """$obj\->uncache_object()""" .el .SS "\f(CW$obj\->uncache_object()\fP" .IX Subsection "$obj->uncache_object()" If you use a Cache driver, returned object will be automatically cached as a result of common retrieve operations. In some rare cases you may want the cache to be cleared explicitly, and this method provides you with a way to do it. .ie n .SS """$obj\->primary_key_to_terms([$id])""" .el .SS "\f(CW$obj\->primary_key_to_terms([$id])\fP" .IX Subsection "$obj->primary_key_to_terms([$id])" Returns \f(CW$obj\fR's primary key as a hashref of values keyed on column names, suitable for passing as \f(CW\*(C`search()\*(C'\fR terms. If \f(CW$id\fR is specified, convert that primary key instead of \f(CW$obj\fR's. .ie n .SS """Class\->datasource()""" .el .SS "\f(CWClass\->datasource()\fP" .IX Subsection "Class->datasource()" Returns the datasource for objects of class \f(CW\*(C`Class\*(C'\fR. That is, returns the \&\f(CW\*(C`datasource\*(C'\fR property of \f(CW\*(C`Class\*(C'\fR. .ie n .SS """Class\->columns_of_type($type)""" .el .SS "\f(CWClass\->columns_of_type($type)\fP" .IX Subsection "Class->columns_of_type($type)" Returns the list of columns in \f(CW\*(C`Class\*(C'\fR objects that hold data of type \&\f(CW$type\fR, as an arrayref. Columns are of a certain type when they are set that way in \f(CW\*(C`Class\*(C'\fR's \f(CW\*(C`column_defs\*(C'\fR property. .ie n .SS """$obj\->set_values(\e%values)""" .el .SS "\f(CW$obj\->set_values(\e%values)\fP" .IX Subsection "$obj->set_values(%values)" Sets all the columns of \f(CW$obj\fR that are members of \f(CW\*(C`\e%values\*(C'\fR to the values specified there. .ie n .SS """$obj\->set_values_internal(\e%values)""" .el .SS "\f(CW$obj\->set_values_internal(\e%values)\fP" .IX Subsection "$obj->set_values_internal(%values)" Sets new specified values of \f(CW$obj\fR, without using any overridden mutator methods of \f(CW$obj\fR and without marking the changed columns changed. .ie n .SS """$obj\->clone()""" .el .SS "\f(CW$obj\->clone()\fP" .IX Subsection "$obj->clone()" Returns a new object of the same class as \fI\f(CI$obj\fI\fR containing the same data, except for primary keys, which are set to \f(CW\*(C`undef\*(C'\fR. .ie n .SS """$obj\->clone_all()""" .el .SS "\f(CW$obj\->clone_all()\fP" .IX Subsection "$obj->clone_all()" Returns a new object of the same class as \fI\f(CI$obj\fI\fR containing the same data, including all key fields. .ie n .SS """Class\->has_column($column)""" .el .SS "\f(CWClass\->has_column($column)\fP" .IX Subsection "Class->has_column($column)" Returns whether a column named \f(CW$column\fR exists in objects of class . .ie n .SS """Class\->column_names()""" .el .SS "\f(CWClass\->column_names()\fP" .IX Subsection "Class->column_names()" Returns the list of columns in \f(CW\*(C`Class\*(C'\fR objects as an arrayref. .ie n .SS """$obj\->column_values()""" .el .SS "\f(CW$obj\->column_values()\fP" .IX Subsection "$obj->column_values()" Returns the columns and values in the given object as a hashref. .ie n .SS """$obj\->column($column, [$value])""" .el .SS "\f(CW$obj\->column($column, [$value])\fP" .IX Subsection "$obj->column($column, [$value])" Returns the value of \f(CW$obj\fR's column \f(CW$column\fR. If \f(CW$value\fR is specified, \&\f(CW\*(C`column()\*(C'\fR sets the first. .PP Note the usual way of accessing and mutating column values is through the named accessors: .PP .Vb 2 \& $obj\->column(\*(Aqfred\*(Aq, \*(Aqbarney\*(Aq); # possible \& $obj\->fred(\*(Aqbarney\*(Aq); # preferred .Ve .ie n .SS """$obj\->is_changed([$column])""" .el .SS "\f(CW$obj\->is_changed([$column])\fP" .IX Subsection "$obj->is_changed([$column])" Returns whether any values in \f(CW$obj\fR have changed. If \f(CW$column\fR is given, returns specifically whether that column has changed. .ie n .SS """$obj\->changed_cols_and_pk()""" .el .SS "\f(CW$obj\->changed_cols_and_pk()\fP" .IX Subsection "$obj->changed_cols_and_pk()" Returns the list of all columns that have changed in \f(CW$obj\fR since it was last loaded from or saved to the database, as a list. .ie n .SS """$obj\->changed_cols()""" .el .SS "\f(CW$obj\->changed_cols()\fP" .IX Subsection "$obj->changed_cols()" Returns the list of changed columns in \f(CW$obj\fR as a list, except for any columns in \f(CW$obj\fR's primary key (even if they have changed). .ie n .SS """Class\->lookup_multi(\e@ids)""" .el .SS "\f(CWClass\->lookup_multi(\e@ids)\fP" .IX Subsection "Class->lookup_multi(@ids)" Returns a list (arrayref) of objects as specified by their primary keys. .ie n .SS """Class\->bulk_insert(\e@columns, \e@data)""" .el .SS "\f(CWClass\->bulk_insert(\e@columns, \e@data)\fP" .IX Subsection "Class->bulk_insert(@columns, @data)" Adds the given data, an arrayref of arrayrefs containing column values in the order of column names given in \f(CW\*(C`\e@columns\*(C'\fR, as directly to the database as \&\f(CW\*(C`Class\*(C'\fR records. .PP Note that only some database drivers (for example, \&\f(CW\*(C`Data::ObjectDriver::Driver::DBD::Pg\*(C'\fR) implement the bulk insert operation. .ie n .SS """$obj\->fetch_data()""" .el .SS "\f(CW$obj\->fetch_data()\fP" .IX Subsection "$obj->fetch_data()" Returns the current values from \f(CW$obj\fR as saved in the database, as a hashref. .ie n .SS """$obj\->refresh()""" .el .SS "\f(CW$obj\->refresh()\fP" .IX Subsection "$obj->refresh()" Resets the values of \f(CW$obj\fR from the database. Any unsaved modifications to \&\f(CW$obj\fR will be lost, and any made meanwhile will be reflected in \f(CW$obj\fR afterward. .ie n .SS """$obj\->column_func($column)""" .el .SS "\f(CW$obj\->column_func($column)\fP" .IX Subsection "$obj->column_func($column)" Creates an accessor/mutator method for column \f(CW$column\fR, returning it as a coderef. .PP Override this if you need special behavior in all accessor/mutator methods. .ie n .SS """$obj\->deflate()""" .el .SS "\f(CW$obj\->deflate()\fP" .IX Subsection "$obj->deflate()" Returns a minimal representation of the object, for use in caches where you might want to preserve space (like memcached). Can also be overridden by subclasses to store the optimal representation of an object in the cache. For example, if you have metadata attached to an object, you might want to store that in the cache, as well. .ie n .SS """Class\->inflate($deflated)""" .el .SS "\f(CWClass\->inflate($deflated)\fP" .IX Subsection "Class->inflate($deflated)" Inflates the deflated representation of the object \fI\f(CI$deflated\fI\fR into a proper object in the class \fIClass\fR. That is, undoes the operation \f(CW\*(C`$deflated = $obj\->deflate()\*(C'\fR by returning a new object equivalent to \f(CW$obj\fR. .SH "TRANSACTION SUPPORT AND METHODS" .IX Header "TRANSACTION SUPPORT AND METHODS" .SS "Introduction" .IX Subsection "Introduction" When dealing with the methods on this class, the transactions are global, i.e: applied to all drivers. You can still enable transactions per driver if you directly use the driver \s-1API.\s0 .ie n .SS """Class\->begin_work""" .el .SS "\f(CWClass\->begin_work\fP" .IX Subsection "Class->begin_work" This enable transactions globally for all drivers until the next rollback or commit call on the class. .PP If begin_work is called while a transaction is still active (nested transaction) then the two transactions are merged. So inner transactions are ignored and a warning will be emitted. .ie n .SS """Class\->rollback""" .el .SS "\f(CWClass\->rollback\fP" .IX Subsection "Class->rollback" This rollbacks all the transactions since the last begin work, and exits from the active transaction state. .ie n .SS """Class\->commit""" .el .SS "\f(CWClass\->commit\fP" .IX Subsection "Class->commit" Commits the transactions, and exits from the active transaction state. .ie n .SS """Class\->txn_debug""" .el .SS "\f(CWClass\->txn_debug\fP" .IX Subsection "Class->txn_debug" Just return the value of the global flag and the current working drivers in a hashref. .ie n .SS """Class\->txn_active""" .el .SS "\f(CWClass\->txn_active\fP" .IX Subsection "Class->txn_active" Returns true if a transaction is already active. .SH "DIAGNOSTICS" .IX Header "DIAGNOSTICS" .IP "\(bu" 4 \&\f(CW\*(C`Please specify a valid column for \f(CIclass\f(CW\*(C'\fR .Sp One of the class relationships you defined with \f(CW\*(C`has_a()\*(C'\fR was missing a \&\f(CW\*(C`column\*(C'\fR member. .IP "\(bu" 4 \&\f(CW\*(C`Please define a valid method for \f(CIcolumn\f(CW\*(C'\fR .Sp One of the class relationships you defined with \f(CW\*(C`has_a()\*(C'\fR was missing its \&\f(CW\*(C`method\*(C'\fR member and a method name could not be generated, or the class for which you specified the relationship already has a method by that name. Perhaps you specified an additional accessor by the same name for that class. .IP "\(bu" 4 \&\f(CW\*(C`keys don\*(Aqt match with primary keys: \f(CIlist\f(CW\*(C'\fR .Sp The hashref of values you passed as the \s-1ID\s0 to \f(CW\*(C`primary_key_to_terms()\*(C'\fR was missing or had extra members. Perhaps you used a full \f(CW\*(C`column_values()\*(C'\fR hash instead of only including that class's key fields. .IP "\(bu" 4 \&\f(CW\*(C`You tried to set inexistent column \f(CIcolumn name\f(CW to value \f(CIdata\f(CW on \f(CIclass name\f(CW\*(C'\fR .Sp The hashref you specified to \f(CW\*(C`set_values()\*(C'\fR contained keys that are not defined columns for that class of object. Perhaps you invoked it on the wrong class, or did not fully filter members of the hash out before using it. .IP "\(bu" 4 \&\f(CW\*(C`Cannot find column \*(Aq\f(CIcolumn\f(CW\*(Aq for class \*(Aq\f(CIclass\f(CW\*(Aq\*(C'\fR .Sp The column you specified to \f(CW\*(C`column()\*(C'\fR does not exist for that class, you attempted to use an automatically generated accessor/mutator for a column that doesn't exist, or attempted to use a column accessor as a class method instead of an instance method. Perhaps you performed your call on the wrong class or variable, or misspelled a method or column name. .IP "\(bu" 4 \&\f(CW\*(C`Must specify column\*(C'\fR .Sp You invoked the \f(CW\*(C`column_func()\*(C'\fR method without specifying a column name. Column names are required to create the accessor/mutator function, so it knows what data member of the object to use. .IP "\(bu" 4 \&\f(CW\*(C`number (of partitions) is required\*(C'\fR .Sp You attempted to define partitioning for a class without specifying the number of partitions for that class in the \f(CW\*(C`number\*(C'\fR member. Perhaps your logic for determining the number of partitions resulted in \f(CW\*(C`undef\*(C'\fR or 0. .IP "\(bu" 4 \&\f(CW\*(C`get_driver is required\*(C'\fR .Sp You attempted to define partitioning for a class without specifying the function to find the object driver for a partition \s-1ID\s0 as the \f(CW\*(C`get_driver\*(C'\fR member. .SH "BUGS AND LIMITATIONS" .IX Header "BUGS AND LIMITATIONS" There are no known bugs in this module. .SH "SEE ALSO" .IX Header "SEE ALSO" Data::ObjectDriver, Data::ObjectDriver::Driver::DBI, Data::ObjectDriver::Driver::SimplePartition .SH "LICENSE" .IX Header "LICENSE" \&\fIData::ObjectDriver\fR is free software; you may redistribute it and/or modify it under the same terms as Perl itself. .SH "AUTHOR & COPYRIGHT" .IX Header "AUTHOR & COPYRIGHT" Except where otherwise noted, \fIData::ObjectDriver\fR is Copyright 2005\-2006 Six Apart, cpan@sixapart.com. All rights reserved.