diff options
author | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-03-09 23:15:56 +0000 |
---|---|---|
committer | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-03-09 23:15:56 +0000 |
commit | 8327a4959a98ad10eb38974aaaddaa1ff7624bda (patch) | |
tree | 28239b730ae8ccac3c79451a6496d6f82371c1cc /LedgerSMB | |
parent | 2994f499bc287114d6ad004e5335c4c5c9d337d9 (diff) |
Fixing numerous issues with new orm code
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@871 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'LedgerSMB')
-rw-r--r-- | LedgerSMB/DBObject.pm | 47 | ||||
-rw-r--r-- | LedgerSMB/Employee.pm | 19 | ||||
-rw-r--r-- | LedgerSMB/Location.pm | 4 |
3 files changed, 38 insertions, 32 deletions
diff --git a/LedgerSMB/DBObject.pm b/LedgerSMB/DBObject.pm index 071acb68..beb95fb2 100644 --- a/LedgerSMB/DBObject.pm +++ b/LedgerSMB/DBObject.pm @@ -29,14 +29,17 @@ use strict; no strict 'refs'; use warnings; -@ISA = (LedgerSMB); +our @ISA = qw(LedgerSMB); sub new { my $lsmb = shift @_; - if (! $lsmb->isa(LedgerSMB)){ - $self->error("Constructor called without LedgerSMB object arg"); my $self = {}; - for $attr (keys $lsmb){ + if (! $lsmb->isa('LedgerSMB')){ + $self->error("Constructor called without LedgerSMB object arg"); + } + + my $attr; + for $attr (keys %{$lsmb}){ $self->{$attr} = $lsmb->{$attr}; } bless $self; @@ -49,34 +52,36 @@ sub exec_method { my $query = "SELECT proname, proargnames FROM pg_proc WHERE proname = ?"; - my $sth = $self->{__dbh}->prepare($query); + my $sth = $self->{dbh}->prepare($query); $sth->execute($funcname); my $ref; - $ref = $sth->fetchrow_hashref(NAME_lc); + $ref = $sth->fetchrow_hashref('NAME_lc'); + my $args = $ref->{proargnames}; + $args =~ s/\{(.*)\}/$1/; + my @proc_args = split /,/, $args; + print "Ref: $ref\n"; + print "Args: $ref->{proargnames}\n"; if (!$ref){ # no such function - $self->error($locale->text("No such function: ") .$funcname; + $self->error("No such function: ", $funcname); die; } my $m_name = $ref->{proname}; - my $args = $ref->{proargnames}; - my @proc_args; - - if ($m_name ~= s/$name\_//){ - push @{$self->{__methods}}, $m_name; - if ($args){ - for $arg (@$args){ - if ($arg =~ s/^in_//){ - push @proc_args, $ref->{$arg}; - } + + if ($args){ + for my $arg (@proc_args){ + if ($arg =~ s/^in_//){ + print "Arg: $arg\n"; + push @proc_args, $self->{$arg}; } } - else { - @proc_args = @_; - } } + else { + @proc_args = @_; + } + print "Arg2s: @_ \n"; $self->callproc($funcname, @proc_args); } - +1; diff --git a/LedgerSMB/Employee.pm b/LedgerSMB/Employee.pm index a299ea86..9ddbbc8f 100644 --- a/LedgerSMB/Employee.pm +++ b/LedgerSMB/Employee.pm @@ -33,33 +33,34 @@ use LedgerSMB; use LedgerSMB::DBObject; our $VERSION = '1.0.0'; -@ISA = (LedgerSMB::DBObject); +our @ISA = qw(LedgerSMB::DBObject); sub AUTOLOAD { + my $self = shift; my $procname = "employee_$LedgerSMB::Employee::Autoload"; - $self->exec_method($procname); + $self->exec_method($procname, @_); } sub save { - my $hashref = shift ($self->exec_method("employee_save")); + my $self = shift; + my $hashref = shift @{$self->exec_method("employee_save")}; $self->merge($hashref, 'id'); } sub get { - my $hashref = shift ($self->exec_method("employee_get")); - $self->merge($hashref, keys $hashref); -} - -sub delete { - $self->exec_method("employee_delete"); + my $self = shift; + my $hashref = shift @{$self->exec_method("employee_get")}; + $self->merge($hashref, keys %{$hashref}); } sub list_managers { + my $self = shift; $self->{manager_list} = $self->exec_method("employee_list_managers"); } sub search { + my $self = shift; $self->{search_results} = $self->exec_method("employee_search"); } diff --git a/LedgerSMB/Location.pm b/LedgerSMB/Location.pm index 3c7eda52..95128e51 100644 --- a/LedgerSMB/Location.pm +++ b/LedgerSMB/Location.pm @@ -34,7 +34,7 @@ use LedgerSMB; use LedgerSMB::DBObject; our $VERSION = '1.0.0'; -@ISA = (LedgerSMB::DBObject); +our @ISA = qw(LedgerSMB::DBObject); sub AUTOLOAD { my $procname = "location_$LedgerSMB::Location::Autoload"; @@ -48,7 +48,7 @@ sub save { sub get { $ref = shift @{$self->exec_method('location_get')}; - $self->merge($ref, keys $ref); + $self->merge($ref, keys %{$ref}); } sub search { |