views:

175

answers:

1

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 total 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
A: 

run trace(ObjectUtil.toString(result)); to dump out the object, then you should see more detail of what is being returned

invertedSpear
That was helpful but how do I make a reference to the COUNT(user_id)?
Adam
result.data[0][0] maybe... it's hard to tell, can you reformat the dump as a code block? it helps me to see it as it came from the trace
invertedSpear
I've reformatted the trace - hope that helps.I also traced - result.data[0][0] - but all it returned was "undefined"
Adam
I think it is `trace(result.data["COUNT(user_id)"]);` but if that doesn't work, try walking down the object in the orig trace. ex `trace(ObjectUtil.toString(result.data));`
invertedSpear
Thanks for you help! trace(result.data["COUNT(user_id)"]); was really close. This is what ended up working - trace(result.data[0]["COUNT(animal_id)"]);
Adam