Hi,

first, thanks for your answers.

Going synchoneously on aAPE server will just stop everithing else until sql
> request ends, you'll exeriment lags on all other responses and messages.
>
> Yes, I'm aware of that, but if the query is simple, the DB server runs on
the same host, and the 'real time' needs for your APE application are not
too much constrained (ie. supporting a few dozen of milliseconds lag), it
could be a good option.


> For your first question, what you could do is, inside your event or
>> command on the server:
>>
>> var sqlFinished = false;
>> var sqlResult = null;
>> sql.query(statement, function(result){
>> sqlResult = result;
>> sqlFinished = true;
>> })
>>
>> while(sqlFinished === false)
>> {
>> //waiting loop
>> }
>> //now work on sqlResult
>>
>>
I already tried something similar ('active wait') but it leads to a complete
freeze of the whole APE server.

I suspect the thread doing the 'read' on the 'connection to DB socket' and
the javascript interpreter's thread being the same.

Ugly but could work. However I would advise against going synchronous,
>> in my experience js is made to work asynchronously, and every time I
>> tried to went against that it ended up badly :)
>>
>>
I think this can be suitable for simple needs. It you look at PHP for
example, the 'synchronous' paradigm is used for every call made to MySQL DB.

Ideally, it could be really interresting to have both approach available
(synchronous and asynchronous) ; the developper would have then the choice
and could use the one that fits it needs.


> For your second question I did not have the issue myself yet, so
>> cannot really help, sorry.
>>
>>
I finally found a workaround using the MySQL 'CASE' statement.
In my program, the field 'username' is the one that may contain empty
strings. Here is my code to avoid the issue:

var myQuery = "
SELECT
    CASE (username)
        WHEN '' then 'guest'
        ELSE username
    END
    AS theUsername,
    session_id,
    user_id
FROM mytable_user_sessions
WHERE
    session_id = '"+sessionId+'
";


Best regards,

Nouk²
-- 
You received this message because you are subscribed to the Google
Groups "APE Project" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/ape-project?hl=en
---
APE Project (Ajax Push Engine)
Official website : http://www.ape-project.org/
Git Hub : http://github.com/APE-Project/

Reply via email to