sqlite COUNT in flex returning [object Object]
I'm sure this is an easy questions and I'm just doing something stupid but I'm really new to all this code.
I'm trying to run a sqlite query in flex to count the to开发者_JAVA技巧tal number of records
I believe its working fine but I just can't figure out how to display the results - all I get back is [object Object].
private function overviewOne():void{
var stmt:SQLStatement = new SQLStatement();
stmt.sqlConnection = sqlConn;
stmt.text = "SELECT COUNT(user_id) FROM tbl_user WHERE status_status ='Away'";
stmt.execute();
var result:SQLResult = stmt.getResult();
acoverviewOne = new Array(result.data);
trace (result.data[0]);
}
Thanks thats helpful.
Here's what I'm getting back.
So how do I make a reference to the COUNT(user_id)?
(flash.data::SQLResult)#0
complete = true
data = (Array)#1
[0] (Object)#2
COUNT(user_id) = 8
lastInsertRowID = 0
rowsAffected = 0
If you change your SQL Statement to:
stmt.text = "SELECT COUNT(user_id) as 'userNo' " +
"FROM tbl_user WHERE status_status ='Away'";
then you can get it something like this:
trace(result.data[0].userNo.toString());
run trace(ObjectUtil.toString(result));
to dump out the object, then you should see more detail of what is being returned
精彩评论