Solved... but too slow!
I managed to hack one of the example scripts but I have found that it runs too slow.
Firstly here is the scenario:
I have a mysql table with about 6000 records in the format (some fileds included as example)
ID,surname,name,Year,class,Line,Tea_title,Tea_GN,Tea_SN
00.157,Nyland,Garron,12,12ComFSLC,3,Mrs,Deborah,Barth
00.157,Nyland,Garron,12,12InfPrLF,6,Ms,Lorr,Hughes
00.157,Nyland,Garron,12,12Math3LB,2,Mrs,Linette,McEndy
00.157,Nyland,Garron,12,12Soc/CLD,4,Mr,Paulya,Turley
01.007,Valencius,Tara,12,12DramaLC,3,Mrs,Katy,Walcolm
01.007,Valencius,Tara,12,12EngA1LA,1,Mrs,Edie,Wronda
01.007,Valencius,Tara,12,12Hosp1LF,6,Mrs.,Annette,Tungston
01.007,Valencius,Tara,12,12Math3LB,2,Mrs,Linette,,McEndy
01.008,Hudson,Jacob,12,12BusStLC,3,Mr,Gerard,Walsh
01.008,Hudson,Jacob,12,12EconLF,6,Mr,Malcolm,Finstool
Now from this I need to make a classlist an put these on a unique page. So I populate an array classes[] with this (theres only about 65 classes) then I loop through each of the classes using the hacked subblock example and produce a class list on each page. It works but is too slow. I have to increase the timeout of querying mysql to be about 3 mins - which is way too slow, before the openoffice document is produced.
Here is my codeing:
FIrst the openoffice file looks like (download it from my server:
the phpcode is as follows:
<?php
include_once('../tbs_class.php');
include_once('../tbsooo_class.php');
include_once('../../common.php');
$sql="SELECT *,count(class) as classtots FROM rec6000 where Year = '11' group by class order by Line,class";
//$sql="select r.*,s.* from rec6000 as r left join 800lines as s on r.ID=s.ID where r.class='12InfPr LC'";
$result= mysql_query ($sql);
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$i==0;
// send a blank one on page 1:
$classes[] = array('classname'=>"" ,'total'=>'','no'=>'');
while($row = mysql_fetch_array($result))
{
$numinclass=$row[classtots]-1;
if ($numinclass > 0) {
$i++;
$classes[] = array('classname'=>"$row[class]" ,'total'=>$numinclass,'no'=>$i);
}
}
// ????????????????????????????????????????????????????????????????????
// #########################################################################3
reset($classes);
//print_r($classes);
$j==0;
while (list($key,$val) = each($classes)) {
$subj=$classes[$key][classname] ;
$sql2="SELECT * from rec6000 where class='$subj'";
$result= mysql_query ($sql2);
$row = mysql_fetch_array($result,MYSQL_ASSOC);
while($row = mysql_fetch_array($result))
{
$TeamListy[$j]['matches'][] = array('town'=>"$row[name]",'score'=>"$row[surname]");
}
$j++;
}
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// instantiate a TBS OOo class
$OOo = new clsTinyButStrongOOo;
// setting the object
$OOo->SetZipBinary('zip');
$OOo->SetUnzipBinary('unzip');
$OOo->SetProcessDir('./tmp');
// create a new openoffice document from the template with an unique id
$OOo->NewDocFromTpl('subblock_nsheets.odt');
// merge data with openoffice file named 'content.xml'
$OOo->LoadXmlFromDoc('content.xml');
$OOo->MergeBlock('mb','array','classes') ;
$OOo->MergeBlock('sb','array','TeamListy[%p1%][matches]') ;
$OOo->SaveXmlToDoc();
// display
header('Content-type: '.$OOo->GetMimetypeDoc());
header('Content-Length: '.filesize($OOo->GetPathnameDoc()));
$OOo->FlushDoc();
$OOo->RemoveDoc();
?>
|
My conclusion is this:
I would love to produce openoffice documents but I need the performance increased. I can at present make them in html in secs then run them throught htmldoc (www.htmldoc.org) to produce a pdf file. OpenOffice is much more preferrable.
Any help would be appreciated
sam