in reply to Re: Perl and MySql - checking tables for column names
in thread Perl and MySql - checking tables for column names

Yeah, no errors, just nothing in the array... I put in debugging code, but no errors returned, just nothing. So, if I put it in the code, how does it output the response? For example, if I do it like this:
my @_mb = $dbh->table_info; my $_tablesAffected = 0; foreach $_k (@_mb) { # Ran code in here... }
What would the @_mb have it in? just table names? So that way I could loop through it like it already does:
foreach $_k (@_mb) { my $_sql = "select * from $_k LIMIT 0"; my $sth2 = $dbh->prepare($_sql); $sth2->execute(); my @_mb2 = @{$sth2->{NAME}}; foreach $_k2 (@_mb2) { # then looking for column names with username: if($_k2 =~ /username/i) { # do what they are looking for } next; } }
or is there a bunch of fields in the @_mb array? Thx, -Richard

Replies are listed 'Best First'.
Re^3: Perl and MySql - checking tables for column names
by Corion (Patriarch) on Jan 23, 2017 at 09:12 UTC

    Maybe now is a good moment to go through the Basic debugging checklist. Consider step 2, printing the contents of your variables instead of guessing at what they might contain, and step 4, using Data::Dumper.

    Also, you haven't told us what database server and what version you are using, and what ->table_info returns. From your usage of LIMIT 0, I assume that it is some kind of MySQL but I prefer not to guess.