[PHPTAL] PHPTAL_RepeatController and PDOStatement
Kornel Lesiński
kornel at aardvarkmedia.co.uk
Sun Feb 3 13:25:49 CET 2008
On 01.02.2008, at 13:12, Julien Fredon 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"
That's the problem indeed. Traversable interface doesn't even offer
methods for returning current key and PDOStatement doesn't count total
number of rows at all.
I've changed SVN version of PHPTAL to be less picky about what it
iterates and use keys obtained from foreach() instead of getting them
via interfaces or array_keys(). This allows basic iteration of
PDOStatement, DOMNodeList, etc.
I'll think about supporting it better (which might require
introspection of template code to check if repeat/last, etc. are
used), but for now, if you need all repeat properties, my suggestion
is to use PDOStatement::fetchAll().
--
regards, Kornel
More information about the PHPTAL
mailing list