List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:February 15 2002 12:10am
Subject:Re: explain table within perl DBI
View as plain text  
At 15:51 -0800 2/14/02, Brian Warn wrote:
>When I run the code  below, information about the first column in each
>table in my list is excluded.  Any ideas why?

Why are you reading a row into @row_ary?

I bet you're thinking that row will correspond to the row of column
headers that you'd see were you to run the query in the mysql client.
But it doesn't.  So you're reading the first row of information (i.e.,
the information for the first table column), but discarding it.

>
>@table_listing=`cat /usr/local/file.txt`;  # contains table list used
>below
>
>$dbh =
>DBI->connect("dbi:mysql:database=dbname;host=hostIP;port=port_number",
>"user", "password") or dienice("Can't connect: $DBI:errstr");
>foreach $table (@table_listing){
>	chomp $table;
>	print "~~~~~~~~~~~~~~~~~~ $table Table ~~~~~~~~~~~~~~~~~\n";
>
>	$statement="explain $table";
>	$sth = $dbh->prepare($statement) or dienice("Can't prepare
>statement: ",$dbh-errstr);
>	$dbh->errstr;
>	$sth->execute;
>	@row_ary = $sth->fetchrow_array;
>	while (($expl0,$expl1,$expl2) = $sth->fetchrow_array){
>		print "$expl0 ....... $expl1 ....... $expl2\n";
>	}
>	$sth->finish;
>	print "\n";
>}
>$dbh->disconnect;
>
>-Brian
>sql, query, mysql, database
>
>
>---------------------------------------------------------------------
>Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
>
>To request this thread, e-mail <mysql-thread100012@stripped>
>To unsubscribe, e-mail <mysql-unsubscribe-paul=snake.net@stripped>
>Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Thread
explain table within perl DBIBrian Warn15 Feb
  • Re: explain table within perl DBIKeith C. Ivey15 Feb
  • Re: explain table within perl DBIPaul DuBois15 Feb