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

review.cgi.. + some dbsql.pm things..

Quote Reply
review.cgi.. + some dbsql.pm things..
i'm just going through the review.cgi source right now and noticed that i rarely used dbsql.pm for my queries.. i am not used to it yet and would like to know if i can do the following..

1. SELECT COUNT(Review) FROM Reviews WHERE LinkID = $id

2. SELECT * FROM Reviews WHERE LinkID = $id AND Review REGEXP ".+" ORDER BY ID Desc LIMIT $OUT{start}, $reviews_per_page

also.. the status of review.cgi..

i haven't worked on it much.. to be honest.. i started again today and made it build html pages instead of making it load from .cgi all the time.. it was an easy change. however.. i am making instructions to do 4 different types of displays.. .cgi, own html page, on detailed page, and have newest X on the detailed with a link to either .cgi or html to view all..

i'm deciding right now whether to release now or after i finish some other things that i wanted to do.. the instructions will take me awhile though.. i always take forever doing instructions..

i'll put a demo up asap.. right now i'm just combining as much as i can to make it work with dbsql.pm.. i originally made it for another sql program with plain sql queries and a bunch of numerous lines of code that can be turned into single line commands with dbsql.pm

anyways.. before i release.. i have to figure out a problem.. i don't want to be bombarded with email about help or anything cause i get enough already and i still have to do my homework you know!? Smile..

jerry
Quote Reply
Re: review.cgi.. + some dbsql.pm things.. In reply to
no actually i was wondering if i could use the query routine to do the two queries above..

$db->query({ });

jerry
Quote Reply
Re: review.cgi.. + some dbsql.pm things.. In reply to
Jerry,

I use DBSQL.pm a lot -- actually for all my stuff now <G>

If you want, send me the code, with the problem, and maybe I can help. I'm good at figuring out the problems and solutions, but often lack the time and patience to make it work (ie: code it). But this is a major addition to Links, and I'll do what I can to get it working -- a lot of people are looking forward to it.



------------------
POSTCARDS.COM -- Everything Postcards on the Internet www.postcards.com
LinkSQL FAQ: www.postcards.com/FAQ/LinkSQL/







Quote Reply
Re: review.cgi.. + some dbsql.pm things.. In reply to
pugdog.. the two selects i need are above..

jerry
Quote Reply
Re: review.cgi.. + some dbsql.pm things.. In reply to
You've lost me a little... DBSQL.pm has a db->do routine, where you can pass it queries that you want to execute.

Is that what you mean?

an example from jump.cgi

$db->do ("DELETE FROM Hits_Track WHERE TO_DAYS(NOW()) - TO_DAYS(created) > 2");

------------------
POSTCARDS.COM -- Everything Postcards on the Internet www.postcards.com
LinkSQL FAQ: www.postcards.com/FAQ/LinkSQL/









[This message has been edited by pugdog (edited December 19, 1999).]
Quote Reply
Re: review.cgi.. + some dbsql.pm things.. In reply to
Cool...thanks Jerry! Smile

I'm really looking forward to it.

------------------
James L. Murray
VirtueTech, Inc.
www.virtuetech.com


Quote Reply
Re: review.cgi.. + some dbsql.pm things.. In reply to
Alex would be the authority, but it looks like certain features of the db->query command are hard coded to return full queries '*' from the search command.

It looks like you'd have to modify the routine to handle your query, but that might be the logical way to go -- create a sub review_query that takes the input you are trying to send it without the overhead of the search parameters.

I don't see the benefit of that, over just passing the query as you've written it through the db->do method. You still hook into all the features of the DBSQL.pm through the package method, and you have control over the query without having to bypass anything.

I've used that method to do what I think you are trying to do.

Quote Reply
Re: review.cgi.. + some dbsql.pm things.. In reply to
actually.. i was taking the lazy approach and asked you guys.. i've actually seen the second query being done on one of the scripts.. the first one however i am not quite sure.. i have seen a count thing.. but not sure where..

jerry
Quote Reply
Re: review.cgi.. + some dbsql.pm things.. In reply to
anyone know any good rating/review places?

i looked at

epinions.com
productopia.com
rateitall.com

and pretty much am going to look through the entire yahoo consumer review category..

just to get an idea of what else i could possibibly add..

if you guys have not seen the graph for review.cgi v2 (which was available to see like 2 months ago) here..

http://www.pdamania.com/graph.cgi?ID=2

it's a PNG image.. should work on all browsers 4.0 and above.. maybe on IE 3.0..

anyways.. it's fully custimizable.. color and all.. and the size is too.. the script is designed to measure all the widths to make the graph come out looking good no matter what the size is.. of course you don't want to give it the width of like 5 and the height of 1000..

and yes.. i am using a 1-5 rating system on my site.. i chose not to use a 1-10..

but there is a variable for review.cgi to easily change it..

jerry
Quote Reply
Re: review.cgi.. + some dbsql.pm things.. In reply to
Well, I was looking at the DBSQL.pm when I was answering, and there is an '*' in the query which obviously is not a modifiable parameter. That's really what would need to be modified is the hard-coded query, and extra parameters added to pass through what you want.

But, if you know the two queries you want to make and you are not going to change them, I don't see why the db->do doesn't fit the bill. db->query handles the various options that can be passed.

The problem I see with the query method as it's written now is with the:

Code:
1. SELECT COUNT(Review) FROM Reviews WHERE LinkID = $id

query, since the count is passed in the routine as 'SELECT COUNT (*) without a replacable parameter. It's counting record hits, not field hits. Unless what you want to do is SELECT COUNT (*) FROM .... but without knowing the database format and what your program is doing, I'm not sure what the query is trying to retrieve. I get the feeling you are trying to add up the values of the 'Review' field and then possibly divide it by the record COUNT.

You've got us working blind, since we don't know the structure of what you are trying to do, it's hard to create a query string.

Going back a step, it might still be easier to clone the db->query method and mod it into the query_review method. The interfaces would then be the same, but the internals would be different to handle the different purposes. Again, it's working blind, so it's hard to say.

Quote Reply
Re: review.cgi.. + some dbsql.pm things.. In reply to
Hi Jerry,

No, I don't think you could use the query() function in DBSQL.pm to do either queries. You would need to use the ->do() and/or ->prepare() functions.

I was thinking I should add an option to query() something like fields => 'ID,Title' and then only ID and Title would be returned. You could then just as easily put fields => 'COUNT(Reviews)'. It would be a pretty easy change.

Cheers,

Alex