Merge branch 'master' into release_0_8_9
[gnash.git] / extensions / mysql / README
blob4f839c00d316b6403fc6bdb96d5c209ecc488ea3
1 This extension is used to MYSQL database access. It's simple and convenient to use with Flash.
3 There is an example of usage of this extension.
5 // creates new object with type mysql_db
6 db = new mysql_db();
8 // bool db.connect(host, dbname, user, passwd)
9 // creates connection to host "host", database "dbname" by user "user" and password "passwd"
10 // The value of host may be either a hostname or an IP address.
11 // If host is NULL or the string "localhost", a connection to the local host is assumed.
12 // The user parameter contains the user's MySQL login ID. If user is NULL or the empty string "",
13 // the current user is assumed. Under Unix, this is the current login name. Under Windows ODBC,
14 // the current username must be specified explicitly. 
15 // The passwd parameter contains the password for user.
18 // if there were errors during MYSQL access, db.err property contains error message
19 if (db.connect("localhost", "gamedb", "vitaly", "abcdefgh") == false)
21   trace("connection error: "+db.err);
25 // opens table
26 tbl = db.open("select * from game");
27 if (tbl == null)
29   trace(db.err);
32 // tbl.size() returns number of table rows
33 trace("size="+tbl.size());
35         
36 // tbl[i].gamename takes value of field 'gamename' of row 'i'
37 for (i = 0; i < tbl.size(); i++)
39   trace(tbl[i].gamename);
42 // closes table & free memory located by table
43 delete tbl;
46 // executes MYSQL statement & returns affected rows
47 // affected rows = -1 means that the error was occured
48 affected_rows = db.run("update game set gamename='newname' where id_game=1");
49 if (affected_rows == -1)
51   trace(db.err);
55 // closes connection
56 delete db;