Raised This Month: $ Target: $400
 0% 

What does this line of code do (SQL oriented)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MALON
Member
Join Date: Jan 2008
Old 02-21-2008 , 22:44   What does this line of code do (SQL oriented)
Reply With Quote #1

PHP Code:
formatexquery500,
        
"select distinct p.alias, s.fin_time, s.cps, s.gcs, g.fin_cnt, s.boosts, s.wpns, s.score from %sscores s join %splayers p on s.user_id = p.user_id join (select user_id, min(score) minscore, count(*) fin_cnt from %sscores where map_name=^"%s^" group by user_id, wpns) g on p.user_id=g.user_id where map_name=^"%s^" and s.score=g.minscore order by s.score limit 20",
        
DB_PREFIXDB_PREFIXDB_PREFIXmapnamemapname 
I'm not sure what the single characters in front of each variable is (if it's even a variable), lik ein p.alias or s.fin_time. I lets say I declare a boolean x, how do I add x to be queried? x boolean,\ ?

They are declared earlier like so:

PHP Code:
formatexquery599,
        
"create table if not exists %sscores (\
        score_id integer primary key %s,\
        score integer,\
        server_ip char(15),\
        user_id integer,\
        map_name varchar(32),\
        fin_time float,\
        cps integer,\
        gcs integer,\
        boosts integer,\
        wpns integer,\
        server_time_stamp integer)"
,
        
DB_PREFIXautoinc )
        
SQL_ThreadQuery(DB_TUPLE,"db_generic_handler",query
I can't figure out where else they are declared or how they get their values. All the database functions from the plugin I'm looking at are many, so I don't know if I posted everything you guys need in order to answer my questions.

I lets say I declare a boolean called rifle, how do I add rifle to be queried? rifle boolean,\ ? How do I query it? b.rifle?

Thanks guys.
MALON is offline
Greenberet
AMX Mod X Beta Tester
Join Date: Apr 2004
Location: Vienna
Old 02-22-2008 , 06:58   Re: What does this line of code do (SQL oriented)
Reply With Quote #2

Code:
from %sscores s join %splayers p
%sscores will be s
%splayers will be p

note
%s will be replaced with DB_PREFIX.
__________________
Greenberet is offline
Send a message via ICQ to Greenberet Send a message via MSN to Greenberet
MALON
Member
Join Date: Jan 2008
Old 02-22-2008 , 09:15   Re: What does this line of code do (SQL oriented)
Reply With Quote #3

Ok that helps. Thank you Greenberet.

Now, where does each variable get it's value? What would be an assignment for those variables? As I said before, the number of database functions I'm trying to mod are many, so it would be ugly for me to copy and paste them.

Is there a general assignment statement that I should look for?

If you guys need all the functions, here is the link to the SMA : http://svn.ian.cammarata.us/index.cg...38&view=markup

Thanks again!
MALON is offline
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 02-22-2008 , 14:04   Re: What does this line of code do (SQL oriented)
Reply With Quote #4

He quoted where they get assigned. In your query, where you tell it what tables to look in, 'FROM TABLE AS short name'. However in the specific query you're looking at the left out the optional 'AS'.
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
MALON
Member
Join Date: Jan 2008
Old 02-22-2008 , 15:57   Re: What does this line of code do (SQL oriented)
Reply With Quote #5

Ok so fin_time float,\ is the declaration, and s.fin_time is the assignment? And it gets the values for fin_time from the table?

My end goal is to add one more column to the table, a boolean. In
order to do this, I need to add that value to the table, then do a
someVar boolean/, then call s.somVar in the query I think.


Huh, I think I just confused myself. It kind of made sense when I was typing it, so I 'll keep what I said.

But if it doesn't make sense, you know why. Plus this quick reply is acting funny, so maybe that's messing with my brain.
MALON is offline
MALON
Member
Join Date: Jan 2008
Old 02-22-2008 , 18:05   Re: What does this line of code do (SQL oriented)
Reply With Quote #6

I also noticed there is g.fin_cnt

What is g?
MALON is offline
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 02-24-2008 , 15:46   Re: What does this line of code do (SQL oriented)
Reply With Quote #7

Your problem is you aren't understanding the query syntax.
Here's a multi-table query with some whitespace, maybe this will help you understand what the highly unstandardized query you're looking at is doing.
Code:
SELECT 
     `table1`.`column1` , `table2`.`column1`
FROM 
     `table1_full_name` AS `table1`
JOIN 
     `table2_full_name` AS `table2` 
     ON `table1`.`column2` = `table2`.`column2`
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:35.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode