Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
simple mysql operations - urgent
Author Message
ChaveS
Journeyman
*

Posts: 69
Likes Given: 0
Likes Received: 0 in 0 posts
Joined: Oct 2012
Reputation: 0



Post: #1
simple mysql operations - urgent
Can someone make me an example to:

a function which create and save a new "table", right
CODE | Column 1 | COLUMN 2 | COLUMN 3
1 | SOME UID | SOME TEXT | SOME NUMBER

And then a function which:
return to sphere de column 1(UID) of line 4, for examle

thanks
12-05-2012 01:00 PM
Find all posts by this user Like Post Quote this message in a reply
Shaklaban
Master
**

Posts: 378
Likes Given: 0
Likes Received: 1 in 1 posts
Joined: Mar 2012
Reputation: 8

DOT

Post: #2
RE: simple mysql operations - urgent
you can use phpmyadmin for creating tables, its easy to use it. in tables always use index, create column with named id and make it auto increment and index. with that every added row will have id, its useful sometimes.

also if you planning to create large tables with uids index uid columns it will boost the performance

about the other question:

PHP Code:
[function database test]
db.query "SELECT * FROM table WHERE uid = '<uid>' ORDER BY id DESC LIMIT 1"

SELECT FROMthis part means select all columns (column 1column 2)
if 
you want to return single column use SELECT COLUMN1 FROM

WHERE uid 
'<uid>' get the row which has uid=self in uids row (put uids in seperate row)

ORDER BY id DESCorder the returning queries by iddescendinguseful if you are making top15 like systems.

LIMIT 1limit to the returning rowsalways use limits because if sphere return large queries server will freeze so if you want to get the players from database which has most kills use:

[
dialog d_top_15_test]
gump codes...
db.query "SELECT * FROM table WHERE columnuid = '<uid>' ORDER BY KILLS DESC LIMIT 15"
local.x=30
local
.y=30
for 0 14
    ref1
=<db.row.<dlocal._for>.columnuid>
    
dtext <local.x> <local.y1152 <ref1.name>
    
local.+= 20
endfor 
12-05-2012 11:47 PM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
ChaveS
Journeyman
*

Posts: 69
Likes Given: 0
Likes Received: 0 in 0 posts
Joined: Oct 2012
Reputation: 0



Post: #3
RE: simple mysql operations - urgent
Exactly what i want, The most important is learn the myadmin commands, and some examples, then ill try my functions on sphere scripting!

It helped! thanks!

If someone has more example please let me know? specially examples creating the tables, for texts etc
On old forum had a lot of examples but on new one, none yet...
12-06-2012 03:04 AM
Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)