Cant read searched array

ZonaX
ZonaX's picture

Joined: 2006-11-02
Posts: 64
Posted: Tue, 2007-02-13 15:33

Hello, i have a problem with getting data from the database, and sending it to a block.

I send a array with the search data to the block. I know that the array contains some data because print_r works and shows me allot lines of info.

But when i try to read a field from the array. I get the following error:

Fatal error: Cannot use object of type GallerySearchResults as array in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\test\gallery2\g2data_gvscs8w43v\smarty\templates_c\%%1126263096\%%19^193^1939C2FA%%ShowNaam.tpl.php on line 7

Line 7 contains:
{$block.persoonnaam.namen.fields}

Where i try to read the "fields" field from the array $block.persoonnaam.namen.

I hope you guys can help me sort this out. :)

- Jim

Signature____________
Have any comment to this post and dont want to place a comment via the forum? Feel free to mail me: Send My A Save Email System :: Visit my module development tutorial at Combined-minds.net

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Tue, 2007-02-13 16:27

you should use it as:

list ($ret, $searchResults) = $gallery->search(...); 
if ($ret) {
    return $ret;
}

and $searchResultsis a GallerySearchResults object, not a row or whatever you might think.
there are plenty of examples on how to use the $searchResults object in g2.

e.g.

while ($row = $searchResults->nextResult()) {
    $yourArray[$row[0]] = $row[1];
}

--------------
Enter the Gallery 2 Theme Contest today!