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,

a hash is a data structure. In your case $category_r is a hash of the record of one category.

$category_r->{'ID'} = the category ID eg. 12
$category_r->{'Name'} = the name of the category (Maincat/subcat/subcat2)
$category_r->{'Description'} = Description of the category (Bla Bala Bla...Text ...BlaBla)
$category_r->{'Has_New_Links'} = "Yes"
and so on...

And the SQL Statement requires a TABLE NAME.

If you want all the with the CategoryID of 12
$get_links = $LINKDB->prepare (" SELECT * FROM Links WHERE CategoryID = ? ORDER BY $LINKS{build_sort_order_category} LIMIT 1000 ");
$get_links->execute(12);

This will do the following query:
"SELECT * FROM Links WHERE CategoryID = '12' ORDER BY Add_Date LIMIT 1000"

Try the query in the SQL Monitor in admin.cgi

If I understand you right, you want to do the following

$get_links = $LINKDB->prepare (" SELECT * FROM Links WHERE Name = ? ORDER BY $LINKS{build_sort_order_category} LIMIT 1000 ");
$get_links->execute ("Yes");

which is quite the same as

$get_links = $LINKDB->prepare (" SELECT * FROM Links WHERE Name = 'Yes' ORDER BY $LINKS{build_sort_order_category} LIMIT 1000 ");
$get_links->execute();

I 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 4068 Aug 29, 2000, 9:16 AM
Post Re: question can you explain this code
startpoint 4046 Aug 30, 2000, 8:59 AM