Now the script bring back everything from one record (which is perfect) but the script is meant to take in a list of id numbers i.e 23,45,3564 and populate a whole table. I am starting to read about fetchrow from the dbi but it seems that will return more than one record that fit a criteria of a single search (am i right?) What i need is that the syntax %FOG{num1,num2,num3}% populates one table with three records the reading in off the numbers is correct but the script above fails becuase it can only do %FOG(num1,num2,num}% .package TWiki::Plugins::FogbugzTablePlugin; use strict; use DBI; use vars qw( $connection ); # cached connection # DBI specification of the connection to the database my $DB_PATH = "DBI:Sybase:server=192.168.70.56"; # DB user my $DB_USER = 'twiki'; # DB user's password my $DB_PASS = 'twiki'; # TWiki ihook sub initPlugin { return 1; } # TWiki hook; this is run on the text being translated to HTML, and is # your opportunity to expand any tags in that text. sub commonTagsHandler { my($text, $topic, $web ) = @_; #$_[0] refers to the first parameter to this function $_[0] =~ s/\bFog(\d+)/_link_to_bug($1)/ge; $_[0] =~ s/%FOG{(.*?)}%/_show_bugs($1)/ge; } # Connect to the DB sub _connect { my $this = shift; unless( $connection ) { $connection = DBI->connect( $DB_PATH, $DB_USER, $DB_PASS, { PrintError => 0, RaiseError => 1, }); } return $connection; } sub _show_bugs { my $args = shift; my @headers = map { "*$_*" } qw/ ID Title Priority Name fix_for Sta +te /; my $fmt = "| %s | %s | %s | %s | %s | %s |\n"; _connect(); my $sth =$connection->prepare(my $sql = "SELECT Bug.ixBug, Bug.sTitle, + Priority.sPriority, Person.sFullName, FixFor.sFixFor, Status.sStatus + FROM Bug, Priority, Person, FixFor, Status WHERE (Bug.ixPriority=Pri +ority.ixPriority) AND (Bug.ixPersonAssignedTo=Person.ixPerson) AND (B +ug.ixStatus = Status.ixStatus) AND (Bug.ixFixFor = FixFor.ixFixFor) A +ND (Bug.ixBug = $args)"); $sth->execute(); while (my @rows = $sth->fetchrow_array() ) { return join '', map {sprintf $fmt, @$_ } \@headers, \@rows; } $sth->finish; } sub _link_to_bug { my $bugid = shift; return '[[http://apwadev01/fogbugz/default.asp?'.$bugid.'][Fog'.$b +ugid.']]'; } 1;
What should commands should i read that may be helpful apart from fetchall ? Plus where can i find an detailed explanation of map? I want to append the string 'FOG' to the begining of the first field of my result not to Headers or other subsequent fields in the table?
Thanks again
In reply to What do i need to read to .. by yoyomonkey
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |