SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 13/01/2011, 08:14 PM   #1
armyoftwo
Gangsta
 
armyoftwo's Avatar
 
Join Date: Nov 2009
Posts: 636
Reputation: 5
Default new to SQL

I'm experienced with MySQL, but its the first time i am working with SQL.
pawn Code:
stock GetAchievementDescription(Achievement[])
{
      new query[128];
      format(query,128,"SELECT Description FROM Achievements WHERE FullName = '%s'",Achievement);
      JA_Result=db_query(JA_Database,query);
      db_get_field(JA_Result,0,query,128);
      db_free_result(JA_Result);
      return query;
}

This code returns the query, but not the fetched data from the field.
__________________
- [INC] Multi language
armyoftwo is offline  
Old 13/01/2011, 09:56 PM   #2
pen_theGun
Big Clucker
 
pen_theGun's Avatar
 
Join Date: Jan 2008
Posts: 179
Reputation: 0
Default Re: new to SQL

http://wiki.sa-mp.com/wiki/Db_get_field_assoc
__________________



pen_theGun is offline  
Old 13/01/2011, 10:28 PM   #3
DVDK
Huge Clucker
 
DVDK's Avatar
 
Join Date: Oct 2010
Posts: 363
Reputation: 0
Default Re: new to SQL

I suggest loading this only once, and saving it into a variable, instead of always load it when need to.
DVDK is offline  
Old 14/01/2011, 01:25 PM   #4
armyoftwo
Gangsta
 
armyoftwo's Avatar
 
Join Date: Nov 2009
Posts: 636
Reputation: 5
Default Re: new to SQL

pawn Code:
stock GetAchievementDescription(Achievement[])
{
      new query[128], result[128];
      format(query,512,"SELECT Description FROM Achievements WHERE FullName = '%s'",Achievement);
      JA_Result=db_query(JA_Database,query);
      db_get_field_assoc(JA_Result,"Description",result, 128);
      db_free_result(JA_Result);
      return result;
}
Still the same
__________________
- [INC] Multi language
armyoftwo is offline  
Old 14/01/2011, 04:18 PM   #5
Sergei
High-roller
 
Sergei's Avatar
 
Join Date: Mar 2008
Location: Slovenia
Posts: 2,870
Reputation: 230
Default Re: new to SQL

Is database even opened? Is description valid field. Is query actually valid? Have you run query in database manager and got result?
__________________
Watch out, scouts everywhere!
Sergei is offline  
 

Thread Tools
Display Modes

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



All times are GMT. The time now is 08:28 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.