Permalink
Browse files

Big patch for bind variables and Oracle

  • Loading branch information...
pudge committed Apr 23, 2001
1 parent f74b360 commit 1be38eeaace3dc099ad5b9ccf9a721ea15382979
View
@@ -31,3 +31,4 @@ rectify it.)
con conductor@certindex.com
Shane Zatezalo shane@lottadot.com
Alvaro del Castillo acs@barrapunto.com
+ Stephen Clouse thebrain@warpcore.org
View
@@ -38,9 +38,8 @@ slash-2.0.0, 2001.04.xx
additions of pagination and viewing recent journal entry
on user's info page *
-* Search now works. XML/RSS search features have been added.
- All you need to do is add &content_type=rss to a search
- query and you will get XML/RSS info.
+* Search now works. XML/RSS search features have been added;
+ use content_type=rss to get data in RSS format
* Catch links to old .shtml article pages and redirect to the
correct location in 404.pl
View
@@ -104,7 +104,11 @@ install: slash plugins
done)
# Create all necessary directories.
- install -d $(SLASH_PREFIX)/bin/ $(SLASH_PREFIX)/sbin $(SLASH_PREFIX)/sql/ $(SLASH_PREFIX)/sql/mysql/ $(SLASH_PREFIX)/sql/postgresql $(SLASH_PREFIX)/themes/ $(SLASH_PREFIX)/themes/slashcode/htdocs/ $(SLASH_PREFIX)/themes/slashcode/sql/ $(SLASH_PREFIX)/themes/slashcode/sql/postgresql $(SLASH_PREFIX)/themes/slashcode/sql/mysql $(SLASH_PREFIX)/themes/slashcode/backup $(SLASH_PREFIX)/themes/slashcode/logs/ $(SLASH_PREFIX)/plugins/ $(SLASH_PREFIX)/httpd/
+ install -d $(SLASH_PREFIX)/bin/ $(SLASH_PREFIX)/sbin \
+ $(SLASH_PREFIX)/sql/ $(SLASH_PREFIX)/sql/mysql/ $(SLASH_PREFIX)/sql/oracle/ $(SLASH_PREFIX)/sql/postgresql \
+ $(SLASH_PREFIX)/themes/ $(SLASH_PREFIX)/themes/slashcode/htdocs/ $(SLASH_PREFIX)/themes/slashcode/sql/ \
+ $(SLASH_PREFIX)/themes/slashcode/sql/mysql $(SLASH_PREFIX)/themes/slashcode/sql/oracle $(SLASH_PREFIX)/themes/slashcode/sql/postgresql \
+ $(SLASH_PREFIX)/themes/slashcode/backup $(SLASH_PREFIX)/themes/slashcode/logs/ $(SLASH_PREFIX)/plugins/ $(SLASH_PREFIX)/httpd/
# Quick hack to avoid the need for "cp -ruv" which breaks under FreeBSD
# is to just copy the directories now. We may end up copying over a file
@@ -149,6 +153,7 @@ install: slash plugins
done)
$(CP) sql/mysql/slashschema_create.sql $(SLASH_PREFIX)/sql/mysql/schema.sql
+ $(CP) sql/oracle/slashschema_create.sql $(SLASH_PREFIX)/sql/oracle/schema.sql
$(CP) sql/postgresql/slashschema_create.sql $(SLASH_PREFIX)/sql/postgresql/schema.sql
# This needs BSD support (and Solaris)...
@@ -73,12 +73,6 @@ sub handler {
}
$slashdb->sqlConnect;
- #Ok, this solves the annoying issue of not having true OOP in perl
- # You can comment this out if you want if you only use one database type
- # long term, it might be nice to create new classes for each slashdb
- # object, and set @ISA for each class, or make each other class inherit
- # from Slash::DB instead of vice versa ...
- $slashdb->fixup;
my $method = $r->method;
# Don't remove this. This solves a known bug in Apache -- brian
View
@@ -8,91 +8,51 @@ package Slash::DB;
use strict;
use DBIx::Password;
use Slash::DB::Utility;
-use vars qw($VERSION @ISA @ISAPg @ISAMySQL);
+use vars qw($VERSION);
($VERSION) = ' $Revision$ ' =~ /\$Revision:\s+([^\s]+)/;
-@ISA = qw[ Slash::Utility ];
-@ISAPg = qw[ Slash::Utility Slash::DB::PostgreSQL Slash::DB::MySQL ];
-@ISAMySQL = qw[ Slash::Utility Slash::DB::MySQL ];
# BENDER: Bender's a genius!
+# Registry of DBI DSNs => Slash::DB driver modules
+# If you add another driver, make sure there's an entry here
+my $dsnmods = {
+ mysql => 'MySQL',
+ Oracle => 'Oracle',
+ Pg => 'PostgreSQL'
+};
+
sub new {
my($class, $user) = @_;
- my $self = {};
my $dsn = DBIx::Password::getDriver($user);
- if ($dsn) {
- if ($dsn =~ /mysql/) {
- require Slash::DB::MySQL;
- @ISA = @ISAMySQL;
- unless ($ENV{GATEWAY_INTERFACE}) {
- require Slash::DB::Static::MySQL;
- push(@ISA, 'Slash::DB::Static::MySQL');
- push(@ISAMySQL, 'Slash::DB::Static::MySQL');
- }
-# } elsif ($dsn =~ /oracle/) {
-# require Slash::DB::Oracle;
-# push(@ISA, 'Slash::DB::Oracle');
-# require Slash::DB::MySQL;
-# push(@ISA, 'Slash::DB::MySQL');
-# unless ($ENV{GATEWAY_INTERFACE}) {
-# require Slash::DB::Static::Oracle;
-# push(@ISA, 'Slash::DB::Static::Oracle');
-## should these be here, in addition? -- pudge
-## Longterm yes, right now it is pretty much pointless though --Brian
-## require Slash::DB::Static::MySQL;
-## push(@ISA, 'Slash::DB::Static::MySQL');
-# }
- } elsif ($dsn =~ /Pg/) {
- require Slash::DB::PostgreSQL;
- require Slash::DB::MySQL;
- @ISA = @ISAPg;
- unless ($ENV{GATEWAY_INTERFACE}) {
- require Slash::DB::Static::PostgreSQL;
- push(@ISA, 'Slash::DB::Static::PostgreSQL',
- 'Slash::DB::Static::MySQL');
- push(@ISAPg, 'Slash::DB::Static::MySQL');
- }
- }
+ if (my $modname = $dsnmods->{$dsn}) {
+ my $dbclass = ($ENV{GATEWAY_INTERFACE})
+ ? "Slash::DB::$modname"
+ : "Slash::DB::Static::$modname";
+ eval "use $dbclass"; die $@ if $@;
+
+ # Bless into the class we're *really* wanting -- thebrain
+ my $self = bless {
+ virtual_user => $user,
+ db_driver => $dsn,
+ # See setPrepareMethod below -- thebrain
+ _dbh_prepare_method => 'prepare_cached'
+ }, $dbclass;
+ $self->sqlConnect();
+ return $self;
+ } elsif ($dsn) {
+ die "Database $dsn unsupported! (virtual user: $user)";
} else {
- warn("We don't support the database ($dsn) specified.\nUsing virtual user '$user' "
- . DBIx::Password::getDriver($user));
+ die "DBIx::Password returned *nothing* for virtual user $user DSN (is the username correct?)";
}
- bless($self, $class);
- $self->{virtual_user} = $user;
- $self->{db_driver} = $dsn;
- $self->SUPER::sqlConnect();
-# $self->init();
- return $self;
}
-# hm. should this really be here? in theory, we could use anything
-# we wanted, including non-DBI modules, to provide the Slash::DB API.
-# but this might break that. aside from this, Slash::DB makes no
-# assumptions about how the API is implemented (well, and the sqlConnect()
-# and init() calls above). maybe instead, we could call
-# $self->SUPER::disconnect(), and have a disconnect() there that calls
-# $self->{_dbh}->disconnect ... ? -- pudge
-
sub DESTROY {
my($self) = @_;
$self->{_dbh}->disconnect
if ! $ENV{GATEWAY_INTERFACE} && defined $self->{_dbh};
}
-# This is for sites running in multiple threaded/process environments
-# where you want to run two different database types
-sub fixup {
- my ($self) = @_;
-
- if ($self->{db_driver} =~ /mysql/) {
- @ISA = @ISAMySQL;
- } elsif ($self->{db_driver} =~ /Pg/) {
- @ISA = @ISAPg;
- }
-}
-
-
1;
__END__
Oops, something went wrong.

0 comments on commit 1be38ee

Please sign in to comment.