What is the best tool to perform a Javascript integration with Mysql?

Asked

Viewed 230 times

0

I am programming a web electronic point system, I am at the beginning still and my knowledge with web programming is still at the beginning. I initially developed the front-end part by HTML and then started thinking about the back-end part.

I was using firebase as back-end (direct scripts in Javascript) but I gave up for some problems and with researches I saw that it was not the best way to be done. I have knowledge in Mysql and thought of using as back-end and Javascript as front-end, but I did not find any tool that can do this for me.

I researched about Node.js but from what I found the beginning was developed by Apis. So I wanted to know if there is any way to use Javascript with any more tool to communicate with the database (Mysql) so that I can enjoy the screens (Forms) already made in HTML.

2 answers

2


First some concepts need to be consolidated. What you do in the frontend does not influence what you do in the backend and vice versa. Both parties communicate through a protocol that they both understand and that does not depend on implementation (it is a common specification).

The frontend will be responsible for generating an HTTP request and will expect to receive an HTTP response; backend expect to receive an HTTP request and generate an HTTP response. That is, to frontend no matter who the backend, as long as he can analyze HTTP requests; for backend no matter who the frontend, provided you make HTTP requests and know how to handle the generated responses.

So the question about what to use in the backend not to lose what was done in frontend makes no sense. You can use Node JS, PHP, Python, C#, C, Java, whichever you prefer on backend and this will not interfere with the decisions of frontend.

And no, Node JS is not only used for Apis. You can serve pages with it smoothly and communicate with Mysql without much difficulty. There are many packages node interacting with Mysql.

  • All right then let’s say I chose Node.js, I saw some examples and the way they were made was via console. Develop database connection commands and commands for example to create a table in a Javascript file and have it executed via a console command (e.g., Node create-table.js). I need to understand how to accomplish this "automatically". What I’m thinking is: the user interacts with the page in a form, I get this data from Javascript and send it to the database using Node.js. I want to understand how to do this correctly and safely.

  • @Tiagoabdalla If you understand the answer correctly, the question you should ask is "how to process an HTTP request with Node?". Seek to answer this and it will solve your doubts.

-2

I will leave my opinion here as an answer, since it is not a specific question.

Answer: PHP backend to work with Mysql

I’ll give you four reasonable grounds:

  1. Mysql has a great tool for managing the database, made in PHP, which is https://www.phpmyadmin.net/
  2. There’s a lot of documentation and kilos of tutorials addressing the relationship between PHP and Mysql, so it’s harder for you to lock in because you don’t have documentation or where to turn when you have questions (ps.: search here in Stackflow for example by PHP tag and other possible languages to see the material difference)
  3. PHP have specific functions to work with Mysql, for example:

    new mysqli("localhost","root",""); mysql_connect("localhost","root"""); mysql_query(); mysql_real_escape_string();

  • As the answer is based on opinion, I left my negative for not agreeing with it. I don’t think the three items listed justify the use of PHP in backend.

  • @Andersoncarloswoss ok

  • @Andersoncarloswoss, I particularly only used nodejs for notifications, I liked your link with the modules, I will download later, thanks for the opinion

  • Just justifying better now that I have more time: item (1) cites Phpmyadmin, but this is just a Mysql client written in PHP, it doesn’t interfere with the language’s decision backend; can even use another language on the server and use Phpmyadmin (although I don’t recommend it); (2) ok, this may be a justification, because, in fact, PHP is one of the languages with a very small learning curve, but in the end it ends up being more harmed than benefited from it [...]

  • [...] given that the bulk of PHP content on the internet is written by those who do not understand what they are writing. For a new user to take advantage is necessary to have a minimum of knowledge to understand what should be filtered and, being new, this is an obstacle in learning; (3) Having functions natively to work with Mysql is a facilitator, but it’s not really a justification. Other languages also have or have very well consolidated packages in the community that do the service.

  • Other than that, in item (3) you ended up mixing the API mysqli with the mysql; given that the second is obsolete and no longer exists in PHP 7, it confuses a lot.

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.