Skip to content
Puritys Chen edited this page May 24, 2015 · 3 revisions

MySql Select Example:

var host = "127.0.0.1";
var user = "test";
var password = "test";
var dbName = "test";

var php = require('phplike/module');
php.mysql_connect(host, user, password);
php.mysql_select_db(dbName);
res = php.mysql_query("select id from book where id = 1;");
console.log(res);

Example Result:

[{ id: '1' }]

MySql Insert Example:

var host = "127.0.0.1";
var user = "test";
var password = "test";
var dbName = "test";

var php = require('phplike/module');
php.mysql_connect(host, user, password);
php.mysql_select_db(dbName);
var res = php.mysql_query(insert into book(name,sn) values('test', '1234');");
var id = php.mysql_inesrt_id();
console.log("new insert id = " + id);

Example Result:

new insert id = 2
Clone this wiki locally