summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xLedgerSMB.pm4
-rw-r--r--LedgerSMB/DBObject.pm16
2 files changed, 18 insertions, 2 deletions
diff --git a/LedgerSMB.pm b/LedgerSMB.pm
index 759ba7d8..8e0dcb3d 100755
--- a/LedgerSMB.pm
+++ b/LedgerSMB.pm
@@ -424,6 +424,7 @@ sub call_procedure {
my %args = @_;
my $procname = $args{procname};
my @args = @{ $args{args} };
+ my $order_by = $args{order_by};
my $argstr = "";
my @results;
for ( 1 .. scalar @args ) {
@@ -431,6 +432,9 @@ sub call_procedure {
}
$argstr =~ s/\, $//;
my $query = "SELECT * FROM $procname()";
+ if ($order_by){
+ $query .= " ORDER BY $order_by";
+ }
$query =~ s/\(\)/($argstr)/;
my $sth = $self->{dbh}->prepare($query);
$sth->execute(@args);
diff --git a/LedgerSMB/DBObject.pm b/LedgerSMB/DBObject.pm
index 2b4b35da..63c27f7c 100644
--- a/LedgerSMB/DBObject.pm
+++ b/LedgerSMB/DBObject.pm
@@ -47,7 +47,8 @@ sub AUTOLOAD {
$type =~ m/::(.*?)$/;
$type = lc $1;
print "Type: $type\n";
- $self->exec_method( procname => "$type" . "_" . $AUTOLOAD, args => \@_ );
+ $self->exec_method( procname => "$type" . "_" . $AUTOLOAD, args => \@_
+ order_by => $order_by);
}
sub new {
@@ -64,8 +65,19 @@ sub new {
$self;
}
+sub set_ordering {
+ my $self = shift @_;
+ my %args = @_;
+
+ if (not defined $self->{_order_method}){
+ $self->{_order_method} = {};
+ }
+
+ $self->{_order_method}->{$args{method}} = $args{column};
+}
+
sub exec_method {
- my ($self) = shift @_;
+ my $self = shift @_;
my %args = @_;
my $funcname = $args{funcname};
my @in_args = @{ $args{args} };