Guest User

Untitled

a guest
Jul 7th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. package null::DB;
  2.  
  3. use strict;
  4. use warnings;
  5.  
  6. use DBI;
  7. use Mojo::Home;
  8. use Data::Dumper;
  9. my $user = "";
  10. my $password = "";
  11. my $dbh;
  12. my $sth;
  13.  
  14.  
  15. sub blog {
  16. my $self = shift;
  17.  
  18. return $dbh if $dbh;
  19.  
  20. my $home = Mojo::Home->new->detect('null');
  21. $dbh = DBI->connect("dbi:mysql:nullim", "$user", "$password");
  22.  
  23. $sth = $dbh->prepare("SELECT * FROM posts ORDER BY id DESC");
  24. $sth->execute();
  25.  
  26. # ->stash(posts => $model->blog('whatever'));
  27.  
  28. my @output = $sth->fetchrow_array();
  29. return @output;
  30. }
  31.  
  32. 1;
Add Comment
Please, Sign In to add comment