"Fossies" - the Fresh Open Source Software Archive

Member "gnash-0.8.10/extensions/mysql/README" (19 Jan 2012, 1624 Bytes) of package /linux/www/old/gnash-0.8.10.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 This extension is used to MYSQL database access. It's simple and convenient to use with Flash.
    2 
    3 There is an example of usage of this extension.
    4 
    5 // creates new object with type mysql_db
    6 db = new mysql_db();
    7 
    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.
   16 
   17 
   18 // if there were errors during MYSQL access, db.err property contains error message
   19 if (db.connect("localhost", "gamedb", "vitaly", "abcdefgh") == false)
   20 {
   21   trace("connection error: "+db.err);
   22 }
   23 
   24 
   25 // opens table
   26 tbl = db.open("select * from game");
   27 if (tbl == null)
   28 {
   29   trace(db.err);
   30 }
   31 
   32 // tbl.size() returns number of table rows
   33 trace("size="+tbl.size());
   34 
   35 	
   36 // tbl[i].gamename takes value of field 'gamename' of row 'i'
   37 for (i = 0; i < tbl.size(); i++)
   38 {
   39   trace(tbl[i].gamename);
   40 }
   41 
   42 // closes table & free memory located by table
   43 delete tbl;
   44 
   45 
   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)
   50 {
   51   trace(db.err);
   52 }
   53 
   54 
   55 // closes connection
   56 delete db;
   57 
   58