phpjquerymysqlajax

Is it possible to interact with a MySQL database without PHP


As the question says, is it possible to interact with a MySQL database created with XAMPP (so, using PhpMyAdmin) without using PHP, but only Javascript/JQuery?

This is a merely theoretical question, I don't want to know how to (but if you know it, I want discard your help).

With this, I don't mean using Ajax to send my request to a .php page that will then interact with the database, but directly interacting without passing through PHP.


Solution

  • In terms of a PHP application, it's not possible to interact with MySQL through JavaScript because JavaScript is executed client side i.e in the browser, it doesn't have access to anything on the server it is being served from.

    However, with nodejs - a JavaScript runtime built on Chrome's V8 JavaScript engine - you can write a complete JavaScript server side application without having to touch PHP. There's a node-mysql module which means you can interact with a MySQL database with JavaScript code.

    Several web application frameworks exist to help you get something up and running like Express, which saves you the burden of having to write up things like routing logic.