Example for DBIx::Recordset

# DBIx::Recordset Example

[- use DBIx::Recordset ; -][$if !defined ($fdat{'!DataSource'}) || !defined ($fdat{'!Table'})|| defined($fdat{'showdsn'}) $][- delete $fdat{'showdsn'}-]

[-@drvs = DBI->available_drivers ; -]Available DBD drivers | First of all you have to specify which database and table you want to access and enter the user and password (if required) For the Datasource you have the following Options: 1.) choose a DBD driver from the list on the left and hit the Show Datasources button, then you can select a Datasource below (if your DBD driver supports the data_sources method) 2.) enter the Data Source directly in the text field below

[- @dsns = DBI->data_sources ($fdat{driver}) if ($fdat{driver}) ; @dsns = () if ($dsns[0] =~ /HASH/ ) ;-]

Datasource: | [$if $#dsns >= 0 $] [$else$] Datasource list not available, enter DSN manual [$endif$]
Table: |
User: |
Password: |
Rows Per Page: | [- $fdat{'$max'} ||= 5 -]

[$elsif defined ($fdat{'cond'}) $][-delete $fdat{'cond'}; $set = DBIx::Recordset -> SetupObject (\%fdat) ; $names = $set -> AllNames () if ($set) ; -]

[$if $DBI::errstr $] ERROR: [+ $DBI::errstr +][$else$]

DataSource: | [+ $fdat{'!DataSource'} +]
Table: | [+ $fdat{'!Table'} +]
User: | [+ $fdat{'!User'} +]
Start Row: | [+ $set -> StartRecordNo +]
SQL Statement: | [+ $set -> LastSQLStatement +]

Fieldname | Operator | Value
--- | --- | ---
[+ $$names[$row] +] |  |

[$hidden$]

[$endif$][$else$][- *set = DBIx::Recordset -> Search (\%fdat) ; -] [- $names = $set -> Names () if ($set) ; -]

[$if $DBI::errstr $] ERROR: [+ $DBI::errstr +][$else$]

DataSource: | [+ $fdat{'!DataSource'} +]
Table: | [+ $fdat{'!Table'} +]
User: | [+ $fdat{'!User'} +]
Start Row: | [+ $set -> StartRecordNo +]
SQL Statement: | [+ $set -> LastSQLStatement +]

[+ $$names[$col] +]
[+ $set[$row]{lc($$names[$col])} +]

[+ $set -> PrevNextForm ('<<Previous Records', 'Next Records>>', \%fdat) +]

[$hidden$]

[$endif$][$endif$]

[- DBIx::Recordset::Undef ('set') ; -]