.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" 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 "Alzabo::Runtime::Row 3pm" .TH Alzabo::Runtime::Row 3pm "2022-06-14" "perl v5.34.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" Alzabo::Runtime::Row \- Row objects .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Alzabo::Runtime::Row; \& \& my $row = $table\->row_by_pk( pk => 1 ); \& \& $row\->select(\*(Aqfoo\*(Aq); \& \& $row\->update( bar => 5 ); \& \& $row\->delete; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" These objects represent actual rows from the database containing actual data. In general, you will want to use the \&\f(CW\*(C`Alzabo::Runtime::Table\*(C'\fR object to retrieve rows. The \f(CW\*(C`Alzabo::Runtime::Table\*(C'\fR object can return either single rows or row cursors. .SH "ROW STATES" .IX Header "ROW STATES" Row objects can have a variety of states. Most row objects are \&\*(L"live\*(R", which means they represent an actual row object. A row can be changed to the \*(L"deleted\*(R" state by calling its \f(CW\*(C`delete()\*(C'\fR method. This is a row that no longer exists in the database. Most method calls on rows in this state cause an exception. .PP There is also a \*(L"potential\*(R" state, for objects which do not represent actual database rows. You can call \f(CW\*(C`make_live()\*(C'\fR on these rows in order to change their state to \*(L"live\*(R". .PP Finally, there is an \*(L"in cache\*(R" state, which is identical to the \&\*(L"live\*(R" state, except that it is used for object's that are cached via the \&\f(CW\*(C`Alzabo::Runtime::UniqueRowCache\*(C'\fR class. .SH "METHODS" .IX Header "METHODS" Row objects offer the following methods: .SS "select (@list_of_column_names)" .IX Subsection "select (@list_of_column_names)" Returns a list of values matching the specified columns in a list context. In scalar context it returns only a single value (the first column specified). .PP If no columns are specified, it will return the values for all of the columns in the table, in the order that are returned by \&\f(CW\*(C`Alzabo::Runtime::Table\->columns\*(C'\fR. .PP This method throws an \&\f(CW\*(C`Alzabo::Runtime::NoSuchRowException\*(C'\fR if called on a deleted row. .SS "select_hash (@list_of_column_names)" .IX Subsection "select_hash (@list_of_column_names)" Returns a hash of column names to values matching the specified columns. .PP If no columns are specified, it will return the values for all of the columns in the table. .PP This method throws an \&\f(CW\*(C`Alzabo::Runtime::NoSuchRowException\*(C'\fR if called on a deleted row. .SS "update (%hash_of_columns_and_values)" .IX Subsection "update (%hash_of_columns_and_values)" Given a hash of columns and values, attempts to update the database to and the object to represent these new values. .PP It returns a boolean value indicating whether or not any data was actually modified. .PP This method throws an \&\f(CW\*(C`Alzabo::Runtime::NoSuchRowException\*(C'\fR if called on a deleted row. .SS "refresh" .IX Subsection "refresh" Refreshes the object against the database. This can be used when you want to ensure that a row object is up to date in regards to the database state. .PP This method throws an \&\f(CW\*(C`Alzabo::Runtime::NoSuchRowException\*(C'\fR if called on a deleted row. .SS "delete" .IX Subsection "delete" Deletes the row from the \s-1RDBMS\s0 and changes the object's state to deleted. .PP For potential rows, this method simply changes the object's state. .PP This method throws an \&\f(CW\*(C`Alzabo::Runtime::NoSuchRowException\*(C'\fR if called on a deleted row. .SS "id_as_string" .IX Subsection "id_as_string" Returns the row's id value as a string. This can be passed to the \&\f(CW\*(C`Alzabo::Runtime::Table\->row_by_id\*(C'\fR method to recreate the row later. .PP For potential rows, this method always return an empty string. .PP This method throws an \&\f(CW\*(C`Alzabo::Runtime::NoSuchRowException\*(C'\fR if called on a deleted row. .SS "is_live" .IX Subsection "is_live" Indicates whether or not the given row represents an actual row in the database. .SS "is_potential" .IX Subsection "is_potential" Indicates whether or not the given row represents an actual row in the datatbase. .SS "is_deleted" .IX Subsection "is_deleted" Indicates whether or not the given row has been deleted .SS "table" .IX Subsection "table" Returns the \f(CW\*(C`Alzabo::Runtime::Table\*(C'\fR object that this row belongs to. .SS "schema" .IX Subsection "schema" Returns the \f(CW\*(C`Alzabo::Runtime::Schema\*(C'\fR object that this row's table belongs to. This is a shortcut for \f(CW\*(C`$row\->table\->schema\*(C'\fR. .SS "rows_by_foreign_key" .IX Subsection "rows_by_foreign_key" This method is used to retrieve row objects from other tables by \&\*(L"following\*(R" a relationship between two tables. .PP It takes the following parameters: .IP "\(bu" 4 foreign_key => \f(CW\*(C`Alzabo::Runtime::ForeignKey\*(C'\fR object .PP Given a foreign key object, this method returns either a row object or a row cursor object the row(s) in the table to which the relationship exist. .PP The type of object returned is based on the cardinality of the relationship. If the relationship says that there could only be one matching row, then a row object is returned, otherwise it returns a cursor. .SH "POTENTIAL ROWS" .IX Header "POTENTIAL ROWS" The \*(L"potential\*(R" row state is used for rows which do not yet exist in the database. These are created via the \f(CW\*(C`Alzabo::Runtime::Table\->potential_row\*(C'\fR method. .PP They are useful when you need a placeholder object which you can update and select from, but you don't actually want to commit the data to the database. .PP These objects are not cached. .PP Once \f(CW\*(C`make_live()\*(C'\fR is called, the object's state becomes \*(L"live\*(R". .PP Potential rows have looser constraints for column values than regular rows. When creating a new potential row, it is ok if none of the columns are defined. If a column has a default, and a value for that column is not given, then the default will be used. However, you cannot update a column in a potential row to undef (\s-1NULL\s0) if the column is not nullable. .PP No attempt is made to enforce referential integrity constraints on these objects. .PP You cannot set a column's value to a database function like \*(L"\s-1\fBNOW\s0()\fR\*(R", because this requires interaction with the database. .SS "make_live" .IX Subsection "make_live" This method inserts the row into the database and changes the object's state to \*(L"live\*(R". .PP This means that all references to the potential row object will now be references to the real object (which is a good thing). .PP This method can take any parameters that can be passed to the \&\f(CW\*(C`Alzabo::Runtime::Table\->insert\*(C'\fR method. .PP Any columns already set will be passed to the \f(CW\*(C`insert\*(C'\fR method, including primary key values. However, these will be overridden, on a column by column basis, by a \*(L"pk\*(R" or \*(L"values\*(R" parameters given to the \f(CW\*(C`(make_live()\*(C'\fR method. .PP Calling this method on a row object that is not in the \*(L"potential\*(R" state will cause an \&\f(CW\*(C`Alzabo::Runtime::LogicException\*(C'\fR .SH "AUTHOR" .IX Header "AUTHOR" Dave Rolsky,