Javascript Query or ORM
is there a w开发者_如何学运维ay to query a database without using php or with an ORM??
If the database built into the browser, then JavaScript running on the client can access it.
Otherwise, if the JS is running on the client then you would need some sort of bridge that can make arbitrary network requests (a signed Java applet for instance) and for the database to be exposed to the world (which is insane).
If both JS and database are server side, then it is entirely possible, but depends on the JS environment. e.g. for Node.js
Most times you want to access a database from JS, it will be JS in the browser, a database on the server and you won't be insane. In these cases you will need an HTTP API which could be written in languages other than PHP (PHP wouldn't be my first choice) and then XMLHttpRequest or JSON-P.
There is a SAAP/SAAS solution to the 'how to query a server database from client javascript' question.
www.rdbhost.com hosts databases with PostgreSQL and provides a JavaScript API to query hosted databases from JavaScript in the browser.
The security issues are handled by a query whitelisting system; the whitelist is populated via a semi-automated training feature, and the server subsequently refuses non-whiteliested queries.
精彩评论