Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

Re: question can you explain this code

Quote Reply
Re: question can you explain this code In reply to
Hi,

this perl code does not fetch the subcategories as you may think when reading the first line

# Fetch the subcategory list.

$get_links = $LINKDB->prepare("SELECT * FROM Links WHERE CategoryID = ? ORDER BY ...);
This line prepares a recordset with a unknown CategoryID (CategoryID =?).

$get_links->execute ($category_r->{'ID'});
Here you tell the recordset ($get_links) to use the CategoryID with the value of $category_r->{'ID'}

$links_r = $get_links->fetchall_arrayref || [];
now you store the records in an array ($links_r ) if you have records. If you don't it will be empty ( || []).

In $links_r you now have all the links with the CategoryID = $category_r->{'ID'}

As for the prepare statement have a look at

http://www.mysql.com/documentation/mysql/commented/manual.php?section=Reference

hope it helps,

regards, alexander

Subject Author Views Date
Thread question can you explain this code startpoint 4166 Aug 27, 2000, 5:41 PM
Thread Re: question can you explain this code
Alex404 4087 Aug 28, 2000, 1:22 AM
Thread Re: question can you explain this code
startpoint 4082 Aug 28, 2000, 3:46 AM
Thread Re: question can you explain this code
Alex404 4091 Aug 28, 2000, 5:58 AM
Thread Re: question can you explain this code
startpoint 4085 Aug 28, 2000, 8:03 AM
Thread Re: question can you explain this code
Alex404 4063 Aug 29, 2000, 1:50 AM
Thread Re: question can you explain this code
startpoint 4056 Aug 29, 2000, 7:23 AM
Thread Re: question can you explain this code
Alex404 4067 Aug 29, 2000, 9:16 AM
Post Re: question can you explain this code
startpoint 4046 Aug 30, 2000, 8:59 AM