Re: Re: DataObject with ITX
| From: | Diego Algorta Casamayou | Date: | Tue, 15 Apr 2003 14:38:45 +0000 |
| Subject: | Re: Re: DataObject with ITX | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-4852@lists.php.net to get a copy of this message | ||
Alan Knowles wrote:
Diego Algorta Casamayou wrote:Thank you Alan! $dataObject->toArray() is perfect for ITX. Now, I have a problem. I have this code: $tpl = new HTML_Template_ITX('./templates'); $tpl->loadTemplateFile('clientsPerCountry.tpl.html'); $country = new DataObjects_Country; $client = new DataObjects_Client; // I want all countries $country->find(); while ($country->fetch()) { $tpl->setCurrentBlock('country'); $countryArray = $country->toArray(); $tpl->setVariable($countryArray); $tpl->setCurrentBlock('client'); // I want al clients from this country $client->CouId = $country->CouId; //This is the Country ID $client->find(); while($client->fetch()) {Does anybody use DataObject AND ITX Templates?I suspect the $dataObject->toArray() may be usefull for that, (not having used ITX that much) I use it alot now for the quickforms integration code, and usually override toArray and setFrom() to provide a few extra variables, eg. function toArray($s='%s') {$ret = parent::toArray($s); $ret['prettyDate'] =date('d M Y',$ret['somedate']); return $ret;} I'm not sure if ITX allows you to send arrays when there may not be template elements defined for them. 'more a case of best match', rather than 'fixed matching', perhaps the ITX authors could comment. Regards Alan
$clientArray = $client->toArray();
$tpl->setVariable($clientArray);
$tpl->parseCurrentBlock();
}
$tpl->parse('country');
}
$tpl->show();
My problem is that it works for the first country, but starting on the second country it doesn't find any matching clients. I put debug=3 in config.ini and I see it's adding a where clause for every field using values from the last record of clients on the FIRST country, BUT, with the correct CouId because it's the only one I change on purpose.
So, I need a way to "reset" the values of my $client object so it doesn't use them for the next find().
¿Any suggestions?
Bytes
DAC