服务器端JavaScript GromJS

openkk 9年前
     <p>GromJS 是一个服务器端的 JavaScript ,实现了 Mozilla SpiderMonkey 的 JavaScript 解释器。它提供了网页设计师和程序员能够使用JavaScript对象的代码用于创建动态网页和网站的脚 本。这可以利用Web服务器上的对象来操纵文件和目录,以及处理客户端发送的数据或资料库,建立动态内容,或者为了实现购物篮。除了标准的 JavaScript对象,类,和职能, GromJS包括支持操纵文件, MySQL和PostgreSQL数据库、SQLite3数据库,会话变量,散列数组,管道, HTTP文件上传,Cookie等。</p>    <p>示例脚本:</p>    <pre class="brush:javascript; toolbar: true; auto-links: false;">//Mysql class; //Create new database and table, insert values, and then select and print //values from table // print("<html><body>"); print("<h1>MySQL database</h1>");  var dbobj = new Mysql(); //Mysql class  //set errno 0 Server.errno(0);  //connect to database server if ( dbobj.connect("hostname.net","usernam","pswrd",3306,"/tmp/mysql.sock")==true ) {  //create database, table, insert values:  //dbobj.query("CREATE DATABASE testdb");  //dbobj.selectdb("testdb");  //dbobj.query("CREATE TABLE testtbl ...");  //dbobj.query("INSERT INTO testtbl ..."); etc. etc.   //query values:  if ( dbobj.selectdb("testdb")==true ) {   //now query   if ( dbobj.query("SELECT id FROM testtbl")==true ) {    //get row as JS Array object from result set    while ( (onerow=dbobj.rowfetch())!=null ) {     //print column:     //1 <br>     //2 <br>     print(onerow[0], "<br>");     }    //optional; results free'd automatically    dbobj.freeresult();    }   }  //error  else {   //ie. cannot select database etc.   print("Error in exec, error [" ,dbobj.error(), "]<br>");   }   //close connection  dbobj.close();  } //error else {  //ie. can not connect to database server etc.  print("Error connecting to database, error [" ,dbobj.error(), "]<br>");  //ie. no permission etc.  print("System errno: " , Server.errnstr(), "<br>");  } print("</body></html>");</pre>    <p><strong>项目主页:</strong><a href="http://www.open-open.com/lib/view/home/1322983693390" target="_blank">http://www.open-open.com/lib/view/home/1322983693390</a></p>    <p></p>