Home : Documentation : DBIx::Recordset
Google Web perl.apache.org

 
Home
 
Features
 
Introduction
 
Documentation
 
README
 
README.v2
 
Configuration
 
Embperl
 
Embperl::Object
 
Embperl::Form::Validate
 
Embperl::Syntax
 
Embperl::Recipe
 
Embperl::Mail
 
1.3.6 documentation
 
DBIx::Recordset
 
Installation
 
Download
 
Support
 
Changes
 
Wiki
 
More infos
 
Add info about Embperl
 
Login

    Stable 2.4.0
    Beta 2.5.0_3
Support the development of Embperl! More...
METHODS
[ << Prev: ARGUMENTS ] [ Content ] [ Next: DATA ACCESS >> ]
 

*set = DBIx::Recordset -E<gt Setup (\%params)>

 

Setup a new object and connect it to a database and table(s). Collects information about the tables which are needed later. Returns a typglob which can be used to access the object ($set), an array (@set) and a hash (%set).

params: setup

 

$set = DBIx::Recordset -E<gt SetupObject (\%params)>

 

Same as above, but setup only the object, do not tie anything (no array, no hash)

params: setup

 

$set = tie @set, 'DBIx::Recordset', $set

 

$set = tie @set, 'DBIx::Recordset', \%params

 

Ties an array to a recordset object. The result of a query which is executed by the returned object can be accessed via the tied array. If the array contents are modified, the database is updated accordingly (see Data access below for more details). The first form ties the array to an already existing object, the second one setup a new object.

params: setup

 

$set = tie %set, 'DBIx::Recordset::Hash', $set

 

$set = tie %set, 'DBIx::Recordset::Hash', \%params

 

Ties a hash to a recordset object. The hash can be used to access/update/insert single rows of a table: the hash key is identical to the primary key value of the table. (see Data access below for more details)

The first form ties the hash to an already existing object, the second one sets up a new object.

params: setup

 

$set = tie %set, 'DBIx::Recordset::CurrRow', $set

 

$set = tie %set, 'DBIx::Recordset::CurrRow', \%params

 

Ties a hash to a recordset object. The hash can be used to access the fields of the current record of the recordset object. (See Data access below for more details.)

The first form ties the hash to an already existing object, the second one sets up a new object.

params: setup

 

*set = DBIx::Recordset -E<gt Select (\%params, $fields, $order)>

 

$set -E<gt Select (\%params, $fields, $order)>

 

$set -E<gt Select ($where, $fields, $order)>

 

Selects records from the recordsets table(s).

The first syntax setups a new DBIx::Recordset object and does the select.

The second and third syntax selects from an existing DBIx::Recordset object.

params: setup (only syntax 1), where (without $order and $fields)

where: (only syntax 3) string for SQL WHERE expression

fields: comma separated list of fieldnames to select

order: comma separated list of fieldnames to sort on

 

*set = DBIx::Recordset -E<gt Search (\%params)>

 

set -E<gt Search (\%params)>

 

Does a search on the given tables and prepares data to access them via @set or %set. The first syntax also sets up a new object.

params: setup (only syntax 1), where, search

 

*set = DBIx::Recordset -E<gt Insert (\%params)>

 

$set -E<gt Insert (\%params)>

 

Inserts a new record in the recordset table(s). Params should contain one entry for every field for which you want to insert a value.

Fieldnames may be prefixed with a '\' in which case they are not processed (quoted) in any way.

params: setup (only syntax 1), fields

 

*set = DBIx::Recordset -E<gt Update (\%params, $where)>

 

*set = DBIx::Recordset -E<gt Update (\%params, $where)>

 

set -E<gt Update (\%params, $where)>

 

set -E<gt Update (\%params, $where)>

 

Updates one or more records in the recordset table(s). Parameters should contain one entry for every field you want to update. The $where contains the SQL WHERE condition as a string or as a reference to a hash. If $where is omitted, the where conditions are buily from the parameters. If !PrimKey is given for the table, only that !PrimKey is used for the WHERE clause.

Fieldnames may be prefixed with a '\', in which case they are not processed (quoted) in any way.

params: setup (only syntax 1+2), where (only if $where is omitted), fields

 

*set = DBIx::Recordset -E<gt Delete (\%params)>

 

$set -E<gt Delete (\%params)>

 

Deletes one or more records from the recordsets table(s).

params: setup (only syntax 1), where

 

*set = DBIx::Recordset -E<gt DeleteWithLinks (\%params)>

 

$set -E<gt DeleteWithLinks (\%params)>

 

Deletes one or more records from the recordsets table(s). Additonal all record of links with have the !OnDelete set, are either deleted or the correspending field is set to undef. What to do is determinated by the constants odDELETE and odCLEAR. This is very helpfull to guaratee the inetgrity of the database.

params: setup (only syntax 1), where

 

*set = DBIx::Recordset -E<gt Execute (\%params)>

 

$set -E<gt Execute (\%params)>

 

Executes one of the above methods, depending on the given arguments. If multiple execute parameters are specified, the priority is =search =update =insert =delete =empty

If none of the above parameters are specified, a search is performed. A search is always performed. On an =update, the !PrimKey, if given, is looked upon and used for the where part of the SQL statement, while all other parameters are updated.

params: setup (only syntax 1), execute, where, search, fields

 

$set -E<gt do ($statement, $attribs, \%params)>

 

Same as DBI. Executes a single SQL statement on the open database.

 

$set -E<gt Reset ()>

 

Set the record pointer to the initial state, so the next call to

Next returns the first row.

 

$set -E<gt First ()>

 

Position the record pointer to the first row and returns it.

 

$set -E<gt Next ()>

 

Position the record pointer to the next row and returns it.

 

$set -E<gt Prev ()>

 

Position the record pointer to the previous row and returns it.

 

$set -E<gt Curr ()>

 

Returns the current row.

 

$set -E<gt AllNames ()>

 

Returns a reference to an array of all fieldnames of all tables used by the object.

 

$set -E<gt Names ()>

 

Returns a reference to an array of the fieldnames from the last query.

 

$set -E<gt AllTypes ()>

 

Returns a reference to an array of all fieldtypes of all tables used by the object.

 

$set -E<gt Types ()>

 

Returns a reference to an array of the fieldtypes from the last query.

 

$set -E<gt Add ()>

 

$set -E<gt Add (\%data)>

 

Adds a new row to a recordset. The first one adds an empty row, the second one will assign initial data to it. The Add method returns an index into the array where the new record is located.

  Example:

  # Add an empty record
  $i = $set -> Add () ;
  # Now assign some data
  $set[$i]{id} = 5 ;
  $set[$i]{name} = 'test' ;
  # and here it is written to the database
  # (without Flush it is written, when the record goes out of scope)
  $set -> Flush () ;

Add will also set the current record to the newly created empty record. So, you can assign the data by simply using the current record.

  # Add an empty record
  $set -> Add () ;
  # Now assign some data to the new record
  $set{id} = 5 ;
  $set{name} = 'test' ;
 

$set -E<gt MoreRecords ([$ignoremax])>

 

Returns true if there are more records to fetch from the current recordset. If the $ignoremax parameter is specified and is true, MoreRecords ignores the $max parameter of the last Search.

To tell you if there are more records, More actually fetches the next record from the database and stores it in memory. It does not, however, change the current record.

 

$set -E<gt PrevNextForm ($prevtext, $nexttext, \%fdat)>

 

$set -E<gt PrevNextForm (\%param, \%fdat)>

 

Returns a HTML form which contains a previous and a next button and all data from %fdat, as hidden fields. When calling the Search method, You must set the $max parameter to the number of rows you want to see at once. After the search and the retrieval of the rows, you can call PrevNextForm to generate the needed buttons for scrolling through the recordset.

The second for allows you the specifies addtional parameter, which creates first, previous, next, last and goto buttons. Example:

 $set -> PrevNextForm ({-first => 'First',  -prev => '<<Back', 
                        -next  => 'Next>>', -last => 'Last',
                        -goto  => 'Goto #'}, \%fdat)

The goto button lets you jump to an random record number. If you obmit any of the parameters, the corresponding button will not be shown.

 

$set -E<gt Flush>

 

The Flush method flushes all data to the database and therefore makes sure that the db is up-to-date. Normally, DBIx::Recordset holds the update in memory until the row is destroyed, by either a new Select/Search or by the Recordsetobject itself is destroyed. With this method you can make sure that every update is really written to the db.

 

$set -> Dirty ()

 

Returns true if there is at least one dirty row containing unflushed data.

 

DBIx::Recordset::Undef ($name)

 

Undef takes the name of a typglob and will destroy the array, the hash, and the object. All unwritten data is written to the db. All db connections are closed and all memory is freed.

  Example:
  # this destroys $set, @set and %set
  DBIx::Recordset::Undef ('set') ;
 

$set -E<gt Begin>

 

Starts a transaction. Calls the DBI method begin.

 

$set -E<gt Rollback>

 

Rolls back a transaction. Calls the DBI method rollback and makes sure that all internal buffers of DBIx::Recordset are flushed.

 

$set -E<gt Commit>

 

Commits a transaction. Calls the DBI method commit and makes sure that all internal buffers of DBIx::Recordset are flushed.

 

$set -E<gt DBHdl ()>

 

Returns the DBI database handle.

 

$set -E<gt StHdl ()>

 

Returns the DBI statement handle of the last select.

 

$set -> TableName ()

 

Returns the name of the table of the recordset object.

 

$set -> TableNameWithOutFilter ()

 

Returns the name of the table of the recordset object, but removes the string given with !TableFilter, if it is the prefix of the table name.

 

$set -> PrimKey ()

 

Returns the primary key given in the !PrimKey parameter.

 

$set -> TableFilter ()

 

Returns the table filter given in the !TableFilter parameter.

 

$set -E<gt StartRecordNo ()>

 

Returns the record number of the record which will be returned for index 0.

 

$set -E<gt LastSQLStatement ()>

 

Returns the last executed SQL Statement.

 

$set -E<gt LastSerial ()>

 

Return the last value of the field defined with !Serial

 

$set -E<gt Disconnect ()>

 

Closes the connection to the database.

 

$set -E<gt Link($linkname)>

 

If $linkname is undef, returns reference to a hash of all links of the object. Otherwise, it returns a reference to the link with the given name.

 

$set -E<gt Links()>

 

Returns reference to a hash of all links of the object.

 

$set -E<gt Link4Field($fieldname)>

 

Returns the name of the link for that field, or <undef> if there is no link for that field.

 

$set -> TableAttr ($key, $value, $table)

 

get and/or set an attribute of the table

 

$key

 

key to set/get

 

$value

 

if present, set key to this value

 

$table

 

Optional, let you specify another table, then the one use by the recordset object.

 

$set -> Stats ()

 

Returns an hash ref with some statistical values.

 

$set -> LastError ()

 

DBIx::Recordset -> LastError ()

 

Returns the last error message, if any. If called in an array context the first element receives the last error message and the second the last error code.


[ << Prev: ARGUMENTS ] [ Content ] [ Next: DATA ACCESS >> ]

© 1997-2012 Gerald Richter / ecos gmbh