0

I have to list the tables for a given database using RoseDB . I know the mysql command for it :

SHOW TABLES in DB_NAME;

How do I implement this in rose DB ? Pleas help

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
user2583714
  • 1,097
  • 2
  • 11
  • 18

1 Answers1

0

It's not really a Rose::DB-specific question. Simply use the database handle how you would normally in DBI:

package My::DB {

    use Rose::DB;
    our @ISA = qw(Rose::DB);

    My::DB->register_db(
        domain   => 'dev',
        type     => 'main',
        driver   => 'mysql',
        ...
    );

    My::DB->default_domain('dev');
    My::DB->default_type('main');
}

use Carp; 

my $db = My::DB->new();
my $sth = $db->dbh->prepare('SHOW TABLES');

$sth->execute || croak "query failed";

while (my $row = $sth->fetchrow_arrayref) {
    print "$row->[0]\n"; 
}
Hans Van Slooten
  • 2,257
  • 2
  • 19
  • 18