Advertisement
Guest User

Untitled

a guest
Mar 13th, 2014
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. EX.pm
  2. -----
  3. has forumdb => sub {
  4. my $self = shift;
  5.  
  6. my $dbh = DBI->connect(
  7. 'dbi:mysql:database=php_BB;host=localhost','user', 'pass',
  8. {RaiseError => 1}
  9. );
  10. return $dbh;
  11. };
  12.  
  13. # This method will run once at server start
  14. sub startup {
  15. my $self = shift;
  16.  
  17. # setup the DB connector here, because mysql disappears, this will stop that from happening
  18. $self->helper('forumdb' => sub { return shift->app->forumdb });
  19. $self->plugin('EX::DBHelpers');
  20. }
  21.  
  22.  
  23. ------------
  24. DBHelpers.pm
  25. ------------
  26. eval { $sth = $self->forumdb->prepare($sql) };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement