Created
July 2, 2009 00:13
-
-
Save lopnor/139194 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!perl | |
use strict; | |
use warnings; | |
use Test::More tests => 2; | |
{ | |
package MySchema; | |
# use base qw(DBIx::Class::Schema::Loader); | |
# __PACKAGE__->loader_options(); | |
use base qw(DBIx::Class::Schema); | |
__PACKAGE__->load_namespaces(); | |
} | |
{ | |
package MySingleton; | |
use parent 'Class::Singleton'; | |
sub _new_instance { | |
my ($class, @args) = @_; | |
return MySchema->connect(@args); | |
} | |
} | |
my $schema = MySingleton->instance(qw(dbi:mysql:test root)); | |
my $schema2 = MySingleton->instance; | |
is $schema, $schema2; | |
is $schema->storage->dbh, $schema2->storage->dbh; | |
use Data::Dumper; | |
warn Dumper $schema->storage->dbh->selectall_arrayref('show tables'); | |
warn Dumper $schema2->storage->dbh->selectall_arrayref('show tables'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment