Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Little mysql example

Also some small error handling improvements
  • Loading branch information...
commit 105d2bbe7e1469a1aa5304f0a3901765f30c23b4 1 parent 5806409
@felixge authored
Showing with 13 additions and 1 deletion.
  1. +10 −0 example/mysql.js
  2. +3 −1 lib/ugly.js
View
10 example/mysql.js
@@ -0,0 +1,10 @@
+require('../test/common');
+var sys = require('sys');
+
+php.invoke('mysql_connect', '192.168.56.1', 'root', 'root', function(e, r) {
+ setTimeout(function() {
+ php.invoke('mysql_query', 'show databases;', r.reference, function(e, r) {
+ sys.p(r.val); // => 5.0.77
+ });
+ }, 1000);
+});
View
4 lib/ugly.js
@@ -15,7 +15,7 @@ exports.createClient = function(options) {
callbacks = [],
buffer = '',
parse = function(chunk) {
- buffer += chunk;
+ buffer += (chunk || '');
var
offset,
@@ -34,7 +34,9 @@ exports.createClient = function(options) {
try {
response = JSON.parse(response);
} catch (e) {
+ e.response = response;
callback(e);
+ return;
}
if (response.error) {
Please sign in to comment.
Something went wrong with that request. Please try again.