Reputation: 13
I'm trying to merge the results of a prepared statement to TBS. Here's my code:
$s = $link->prepare("SELECT * FROM newsletters WHERE newsletter_id = :newsletter_id");
$s->bindParam(":newsletter_id",$newsletter_id);
$s->execute();
$newsletter = $s->fetch(PDO::FETCH_ASSOC);
$tbs->MergeBlock('$newsletter ', $newsletter );
But I can't get the results fields. I get errors like the following:
TinyButStrong Error in field [newsletter.title...]: item 'title' is not an existing key in the array.
I can't find my error.
Upvotes: 0
Views: 42
Reputation: 5552
MergeBlock()
is for merging a recordset , so you should use $s->fetchAll()
instead of $s->fetch()
. The section of the template will be repeated for each record.
But if you have to merge a standalone record, use MergeField()
instead of MergeBlock()
. The single fields will be merged one by one without repeating.
Upvotes: 0