简体   繁体   English

如何在mysql数据库中插入我的代码JS

[英]how to insert my code JS in mysql database

I'm a beginner in JavaScript, and I want to store JavaScript code snippets in a MySQL database,in a table named tag in order to do an automatic tracking.我是 JavaScript 的初学者,我想将 JavaScript 代码片段存储在 MySQL 数据库中名为tag的表中,以便进行自动跟踪。 How can I do that?我怎样才能做到这一点?

Here is my snippet of code that exists in the code of my Node.js server这是我的 Node.js 服务器代码中存在的代码片段

$(document).ready(function(data) {
 $('#poke').click(function(){
        socket.emit('alarm')
        })
   });

poke is the ID of my button. poke是我的按钮的 ID。

This is my table tag , where I want to insert my JavaScript code:这是我的表tag ,我想在其中插入我的 JavaScript 代码:

在此处输入图片说明

Use following query - I assume that you put code to 'name' column - working example here )使用以下查询 - 我假设您将代码放入“名称”列 -此处的工作示例)

insert into tag(tag_id, type, action_id,  name) values(1,1,1, "
$(document).ready(function(data) {
 $('#poke').click(function(){
        socket.emit('alarm')
        })
   });
");

The page from w3schools explains the SQL syntax in more detail: w3schools的页面更详细地解释了 SQL 语法:

INSERT INTO table_name (column1, column2, column3, ...)
VALUES (value1, value2, value3, ...);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM