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

Back to Database.SQLite Class Summary

Windows, Mac OSX, Linux



An Array

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.

A query must be made to the database (using Database.SQLite.runQuery()) before calling this function.

Example Code
//Prompts the data in Row 1, Field 4:
mdm.Database.SQLite.runQuery("SELECT * FROM mytable")
var dataSet:Array = mdm.Database.SQLite.getData();

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

mdm.Database.SQLite Class Example Downloads
Simple SQLite Example

User Comment by DLD on 9th February 2008 - 00:02
An option to create array that contains the field names instead of field numbers would be very useful. I'm so used to use Mysql with PHP so I kinda miss that option. It makes the positioning of those values so much easier... That would be single the addition to the database class that so it would be perfect.

User Comment by Dan Woolloff on 13th April 2008 - 12:32
Hi DLD, You can use the "PRAGMA table_info(table_name)" query to get a list of the columns and their indexes. I also prefer to use column names so I simply create variables with the same name as the column name and give them the value of the column index, meaning you can pass them to any Zinc SQLite method that expects the index.

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