Antic,
look this gist i made with and example of how to use mysql module
on node.js http://bit.ly/xaBAK1 , it has a simple query and a loop over the
results.
Best regards.
2012/3/1 Scott Straley <[email protected]>
> Antic,
>
> Remember to use callbacks and closure when you're dealing with
> time-related issues such as user input, databases, or remote procedures. I
> haven't worked with mysql (only mongo), but the pseudocode would be
> something like:
>
>
> var yourfunction = function(response_object){
>> open_database(connection_info, function(db){
>> db.perform_query("select blah from bloo where bleep",
>> function(results){
>> response_object.sendSomeData(results.someData());
>> });
>> });
>> }
>
>
> Notice how closure ensures that the response_objects makes it to the
> innermost callback function. It's there that you send the data to the
> framework or TCP/IP port or however you're presenting your information to
> the user. It would help more to see a code sample.
>
> ~ Scott
>
>
> On Thursday, March 1, 2012 3:34:42 AM UTC-5, antic wrote:
>>
>> i have a problem. i want to read some data from the database and write it
>> on to a page to show in the browser and i am having some trouble. im using
>> node-mysql. i can write it succesfully in the console line but when i put
>> the same code in a function and export it and call it in the other file it
>> does not work. lets say i have one index.js where i want to show data in
>> html and antoher file mysqldb.js where the functions for the database are.
>> could someone please write me a small example i would be gratefull. thanks
>> in advance!
>>
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" 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/nodejs?hl=en?hl=en
>
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" 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/nodejs?hl=en?hl=en