= 'SELECT foo FROM bar WHERE id = 42'; $result = mysql_query($sql, $link); echo $result; DB.query(‘SELECT foo FROM bar WHERE id = 42’, function(err, rows){ doSth(rows); //deal with rows }); PHP sync way node async way Thursday, July 4, 13
= require('./circle.js'); console.log( 'The area of a circle of radius 4 is ' + circle.area(4)); }; var PI = Math.PI; exports.area = function (r) { return PI * r * r; }; exports.circumference = function (r) { return 2 * PI * r; The contents of circle.js: Thursday, July 4, 13
// do some stuff ... callback(null, 'one'); }, function(callback){ // do some more stuff ... callback(null, 'two'); } ], function(err, results){ // results is now equal to ['one', 'two'] }); Thursday, July 4, 13
} x() node.js:134 throw e; // process.nextTick error, or 'error' event on first tick ^ Error: my silly error at x (/Users/benno/apkudo/test.js:2:11) at Object. (/Users/benno/apkudo/test.js:5:1) at Module._compile (module.js:402:26) at Object..js (module.js:408:10) at Module.load (module.js:334:31) at Function._load (module.js:293:12) at Array. (module.js:421:10) at EventEmitter._tickCallback (node.js:126:26) Thursday, July 4, 13
'error' event on first tick ^ Error: my silly error at x (/Users/benno/apkudo/test.js:2:11) at Array.onTick (/Users/benno/apkudo/test.js: 11:6) at EventEmitter._tickCallback (node.js:126:26) Thursday, July 4, 13