diff options
author | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2006-09-22 06:11:45 +0000 |
---|---|---|
committer | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2006-09-22 06:11:45 +0000 |
commit | 1be032cc33531158196d406f44de3fe8f1e8e8b0 (patch) | |
tree | acdcf3b969c6b957b76473f1cc896a6e0efba557 /LedgerSMB | |
parent | 4228c08809b0ff57b13061ab0cb1d3193ba86f4c (diff) |
Now db custom fields are cached in the $form object. Also there is now a
$form->{dbh} which is a noauto database handle to be used for all db activities.
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@128 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'LedgerSMB')
-rwxr-xr-x | LedgerSMB/Form.pm | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/LedgerSMB/Form.pm b/LedgerSMB/Form.pm index f9a6477c..255ff849 100755 --- a/LedgerSMB/Form.pm +++ b/LedgerSMB/Form.pm @@ -1261,6 +1261,25 @@ sub print_button { # Database routines used throughout +sub db_init { + my ($self, $myconfig) = @_; + $self->{dbh} = $self->dbconnect_noauto($myconfig); + + my $query = + "SELECT t.extends, + coalesce (t.table_name, 'custom_' || extends) + || ':' || f.field_name as field_def + FROM custom_table_catalog t + JOIN custom_field_catalog f USING (table_id)"; + my $sth = $self->{dbh}->prepare($query); + $sth->execute; + my $ref; + while ($ref = $sth->fetchrow_hashref(NAME_lc)){ + push @{$self->{custom_db_fields}{$ref->{extends}}}, + $ref->{field_def}; + } +} + sub dbconnect { my ($self, $myconfig) = @_; |