is there a way to query a database without using php or with an ORM??
-
what do you want to use. because there are number of different databases (including client/browser side ones /in html5/). If we assume you ask about Javascript to access a server-side DB, the answer is no you don't. You need a server side programming. – venimus May 09 '11 at 13:51
-
This is a possible duplicate: http://stackoverflow.com/questions/857670/how-to-connect-to-sql-server-database-from-javascript. Can you be a bit more specific? Does the other question answer yours? Or isn't this about connecting to a DB using some `ActiveXObject` ? – Lukas Eder May 09 '11 at 13:56
2 Answers
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.
-
my question was for making query from client to server, thanks both answers are really clear. and which language you would choose for writing APIs? – Zerho May 10 '11 at 16:51
-
1Perl, but whatever language you like best will do (including JavaScript if you want to get to grips with node.js or another SSJS implementation) – Quentin May 11 '11 at 09:37
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.

- 929
- 2
- 8
- 20