Database.MySQL.getData() This page was last modified over 30 day(s) ago and has 2 comment(s)


Back to Database.MySQL Class Summary

Availability
Windows, Mac OSX, Linux

Usage
mdm.Database.MySQL.getDelimited():Array

Parameters
None

Returns
An Array

Description
Returns the full query data to a 2 dimensional array. The first dimension contains the row number and the second dimension contains the field number.

Notes
A Query must first be executed with mdm.Database.MySQL.runQuery()

Example Code
//Prompts the data in Row 1, Field 4:
mdm.Database.MySQL.runQuery("SELECT * FROM mytable")
var dataSet:Array = mdm.Database.MySQL.getData();
mdm.Dialogs.prompt(dataSet[0][3])

//This example will display the entire contents of the specified table in a dialog prompt
var tableName:String = "myTable";
mdm.Database.MySQL.runQuery("SELECT * FROM "+tableName)
var dataSet:Array = mdm.Database.MySQL.getData();
var myText = ""
for (i=0; i<dataSet.length; i++) {
    for (n=0; n<dataSet[0].length; n++) {
        myText += "FIELD"+(n+1)+" = "+dataSet[i][n]+", ";
    }
    myText += "\n";
}
mdm.Dialogs.prompt(myText);

mdm.Database.MySQL Class Example Downloads
No Example Downloads Available


User Comment by MDM Admin on 12th February 2008 - 17:19
Users should note that Zinc 3.0 uses "0" based Index Values as opposed to Zinc 2.5 which used "1" based Indexes. So, for example, to retrieve the first row, you should access [0] instead of [1].

User Comment by Lars Rex on 19th July 2012 - 20:10
You eks - is not valid in syntax . you have forgot the for (Var i = 0 ............ and the same with n ,

//This example will display the entire contents of the specified table in a dialog prompt
var tableName:String = "myTable";
mdm.Database.MySQL.runQuery("SELECT * FROM "+tableName)
var dataSet:Array = mdm.Database.MySQL.getData();
var myText = ""
for (var i=0; i for (var n=0; n myText += "FIELD"+(n+1)+" = "+dataSet[i][n]+", ";
}
myText += "\n";
}
mdm.Dialogs.prompt(myText);

Registered Users must be logged in to 'MyAccount' to add a Comment - Log In Here
  After Logging In, Click Here to Refresh This Page