As far as I know a PDOStatement object implements the Countable interface for the number of columns not the rows. This means that the repeat controller will give a 'wrong' value for the 'end' attribute in the loop.
To solve it either you need to modify the RepeatController to detect PDOStatement objects and fetch all the rows at instantiation time and count them, or you manually preprocess the statement and convert it to an array or an iterable object before using it. Another option would be to rewrite the Repeat attribute to only work with and Iterator object (using ArrayObject for arrays) and change the logic it uses to detect the last item in the set by pre-fetching the next item at the end of the loop and checking its validity. Iván On Feb 1, 2008 2:12 PM, Julien Fredon <[EMAIL PROTECTED]> wrote: > > Hello phptal users, > > I have a problem with PHPTAL and PDO (www.php.net/pdo) when i use > tal:repeat. > PHPTAL_RepeatController seems angry with PDOStatement. > > PDOStatement is not "Iterator" but it's "Traversable" > I changed the following code (RepeatController line 58) : > > if ($source instanceof IteratorAggregate) $source = > $source->getIterator(); > else if (!is_array($source) && !($source instanceof Iterator)) > $source = array(); > > with > > if ($source instanceof IteratorAggregate) $source = > $source->getIterator(); > else if (!is_array($source) && !($source instanceof Iterator) && > !($source instanceof Traversable)) $source = array(); > > but i'm not sure that it's the good or the best solution. > > > > -- > > > > Julien > > _______________________________________________ > PHPTAL mailing list > PHPTAL@lists.motion-twin.com > http://lists.motion-twin.com/mailman/listinfo/phptal > > _______________________________________________ PHPTAL mailing list PHPTAL@lists.motion-twin.com http://lists.motion-twin.com/mailman/listinfo/phptal