summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-05-08 16:06:22 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-05-08 16:06:22 +0000
commit2aa92462c19709880a4dc629aa5e7c3a59ed89f6 (patch)
tree17f2c3b6649de6936220cc3842f7ddde88defd3a
parent736c183e20429e6e9ccfed08a6d0bddecd7c8d55 (diff)
Added stored procedure collation handling stub
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1172 4979c152-3d1c-0410-bac9-87ea11338e46
-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} };