From: JT S. <jt...@pl...> - 2004-07-06 20:58:33
|
Pardon me if I misunderstood what you're trying to do. Your query only returns one row of data because you're where clause includes the primary key, which by definition will only give you one row of data. If you want to get back all the rows that match the primary keys in that array try something like: $sql = "select...from...where priKey in (".join(",",@PKlist).")"; Again, if I misunderstood, I'm sorry about that. If I haven't, the join trick should work nicely. Also, another neat trick (if you don't mind your template variables being named your field names) is that you can dump the paginator directly into your template variables like this: $var{data_loop} = $p->getPageData; # this creates your loop $p->appendTemplateVars(\%var); # this adds your paginator variables NOTE: Requires 6.0 or higher. On Tue, 06 Jul 2004 16:43:09 -0400 "Roy Johnson" <RJo...@sp...> wrote: >Greetings, > >I'm slowly learning the WebGUI API and am currently developing a macro for our company >and have a few questions. Before I ask my question, I'm basing most of my code and >assumptions on the SQLReports Wobject. > >Basically, I have an array with a single column of values that represent primary key >field values in a table. I'm executing the query once for each element of the array >and returning multiple columns from the query using the >WebGUI::Paginator->SetDataByQuery() method. > >ex: > >foreach $primaryKey (@PrimaryKeyList) { > > $sql = "Select value1, value2, From tblBlah Where primaryKey=$primaryKey"; > > $page = WebGUI::Paginator->new($url); > $err = $page->setDataByQuery($query, $dbh); > $rowData = $page->getPageData(); > > #Code to create hashes necessary for returning Template vars > >} > >The code that I have is working but I'm not sure that I'm approaching the problem >correctly. Because my query will never return more than one row during a single >itteration of the foreach loop (because the where clause is based on a primary key >field) it seems this is the wrong approach to take. > >The problem is that I must execute the query once for each value in my array so the >cummulative result (what is sent to the macro in the form of template vars) almost >always has more than one row of information. So my template for the macro looks >something like this: > ><tmpl_loop rows_loop> ><tmpl_var row.field.value1.value><br/> ><tmpl_var row.field.value2.value> ></tmpl_loop> > >In case anyone is wondering why I didn't write my SQL statement better to avoid the >need for an array of the necessary primary key values, it's because we are not running >MySQL 4.1 and don't have the support for subselects and the 'having' keyword. If we >were, I could accomplish what I'm doing without the need for the array of primary key >values. > >Sorry for the long post. If anyone could nudge me in the right direction for this type >of programming challenge I would GREATLY appreciate it. > >Thanks, > >Roy Johnson > > > >------------------------------------------------------- >This SF.Net email sponsored by Black Hat Briefings & Training. >Attend Black Hat Briefings & Training, Las Vegas July 24-29 - >digital self defense, top technical experts, no vendor pitches, >unmatched networking opportunities. Visit www.blackhat.com >_______________________________________________ >Pbwebgui-development mailing list >Pbw...@li... >https://lists.sourceforge.net/lists/listinfo/pbwebgui-development JT ~ Plain Black Create like a god, command like a king, work like a slave. |