Hello,
I'm using server-side script (actionscript) and executeQuery and return the results in the DatabaseManager object from mysql What I would like to do is build a dataProvider from these results and send it back down to the client to populate a datagrid but I don't think this can be done in AS1 on the server.
On the server, I can access the DatabaseManager object and get the field names from the query results just fine. When I try to pass this same object back to the client for processing, it appears the results are lost.
Is this possible or do I need to step through the DatabaseManager object on the server and build an array of the values... passing the array back down to the client?
What is the best approach for what I'm trying to achieve?
Regards,
Brent
DatabaseManager Object Server to Client?
-
BattleSpace
- Posts: 41
- Joined: 03 Oct 2005, 20:53
- Location: Phoenix, AZ
- Contact:
-
BattleSpace
- Posts: 41
- Joined: 03 Oct 2005, 20:53
- Location: Phoenix, AZ
- Contact:
Re: DatabaseManager Object Server to Client?
I should add that building an array of query results works but I'm just not sure it is the best solution.... or is it?BattleSpace wrote: ... or do I need to step through the DatabaseManager object on the server and build an array of the values... passing the array back down to the client?
Any opinions?
Brent
Not quite sure if I understood you right but it seems that maybe be your problem is the same or similar to the one discussed here http://forums.smartfoxserver.com/viewtopic.php?t=1766.
About the approach you use - honestly don't know. I think it's good enough - it must something similar to that SFS does behind the scenes to send objects from server side extension to the clients(or I'm wrong).
About the approach you use - honestly don't know. I think it's good enough - it must something similar to that SFS does behind the scenes to send objects from server side extension to the clients(or I'm wrong).
-
BattleSpace
- Posts: 41
- Joined: 03 Oct 2005, 20:53
- Location: Phoenix, AZ
- Contact:
Thanks for the response...
Yes, that thread is using the "populate array" solution that is working for me as well. I'm using XML and have no problem with the protocol.
My utltimate goal was to eliminate the "array" step and either go straight to a dataprovider (which doesn't seem possible in AS1) or send the query down to the client where it is possible to convert to a dataprovider because I'm using AS3.
Sending the query directly to the client will trace the same as on the server but once I step into it in a For loop like on the server nothing is there.
So instead of this:
sql query (server)
array (server)
dataprovider (client)
I wanted to do this:
sql query (server)
dataprovider (server) - send to client
or
sql query (server)
dataprovider (client)
I didn't think it would be necessary to add everything to an array first.
Regards,
Brent
Yes, that thread is using the "populate array" solution that is working for me as well. I'm using XML and have no problem with the protocol.
My utltimate goal was to eliminate the "array" step and either go straight to a dataprovider (which doesn't seem possible in AS1) or send the query down to the client where it is possible to convert to a dataprovider because I'm using AS3.
Sending the query directly to the client will trace the same as on the server but once I step into it in a For loop like on the server nothing is there.
So instead of this:
sql query (server)
array (server)
dataprovider (client)
I wanted to do this:
sql query (server)
dataprovider (server) - send to client
or
sql query (server)
dataprovider (client)
I didn't think it would be necessary to add everything to an array first.
Regards,
Brent
Hmm I take a quick look at the problem you have.
For me it seems that executeQuery returns ArrayList. And the array list internally stores the data as array. So you can get the array this way:
where result stores the result from calling executeQuery.
I'm sorry I don't have much experience(I don't have any) in using dbManager. So unfortunately that the only think I can help.
About the building data provider - I'm not sure what you mean but basically try to do as little things you can on the server side when this not affect the security and doesn't generate significant more bandwidth, because even if one operation cost little resources when you have 100 or 1000 user this can slow down the server.
For me it seems that executeQuery returns ArrayList. And the array list internally stores the data as array. So you can get the array this way:
Code: Select all
var resultArray = result.toArray()I'm sorry I don't have much experience(I don't have any) in using dbManager. So unfortunately that the only think I can help.
About the building data provider - I'm not sure what you mean but basically try to do as little things you can on the server side when this not affect the security and doesn't generate significant more bandwidth, because even if one operation cost little resources when you have 100 or 1000 user this can slow down the server.
-
BattleSpace
- Posts: 41
- Joined: 03 Oct 2005, 20:53
- Location: Phoenix, AZ
- Contact:
-
BattleSpace
- Posts: 41
- Joined: 03 Oct 2005, 20:53
- Location: Phoenix, AZ
- Contact:
I finally got around to revisit this issue and try the "toArray" on the results of the executeQuery on the server.
When I send the array back to the client and trace it I get:
[Ljava.lang.Object;@a53de4
With the portion beyond the ";" changing each time.
It isn't an array... but just a string. The only way I actually get this into an array is to step through the entire query results on the server and add them to an array... then send that to the client.
Oh well...
When I send the array back to the client and trace it I get:
[Ljava.lang.Object;@a53de4
With the portion beyond the ";" changing each time.
It isn't an array... but just a string. The only way I actually get this into an array is to step through the entire query results on the server and add them to an array... then send that to the client.
Oh well...
This is related with how the internal serializer works with native Actionscript objects and Java objects... to make a long story short it does not work with java arrays and expects native Actionscript arrays.
So, at the moment I'd recommend to build an AS array/object from the result set and send it to the client.
This is also suggesting new improvements to add to the next release: we'll add better support to java lists and arrays to simplify this process.
So, at the moment I'd recommend to build an AS array/object from the result set and send it to the client.
This is also suggesting new improvements to add to the next release: we'll add better support to java lists and arrays to simplify this process.