我可以在FireFox中执行MySQL SQL语句吗? [英] Can I execute MySQL SQL statements in FireFox?

查看:655
本文介绍了我可以在FireFox中执行MySQL SQL语句吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个名为 greasemonkey 的FireFox插件,您可以使用该插件在指定的页面上执行某些JavaScript代码。我想知道是否有一种方式,我可以嵌入SQL语句(MySQL)在JavaScript。如果是这样,我可以提取我需要的信息,并将它们保存到我的MySQL数据库供以后使用。这是可能吗?

There is a FireFox plugin called greasemonkey with which you can execute some piece of JavaScript code on the page you specified. I want to know whether there is a way that I can embed SQL statements (MySQL) in JavaScript. If so, I can extract the information I need and save them to my MySQL database for later use. Is this possible?

谢谢。

推荐答案

无法在Firefox中执行MySQL语句,尽管您可以立即在Chrome中

Strictly speaking, you cannot execute MySQL statements in Firefox, although you can in Chrome for the moment.

在Firefox中,您可以创建和使用IndexedDB数据库 - 更支持的浏览器数据库方法(实际上是HTML5规范)。

In Firefox you can create and use IndexedDB databases -- a more supported browser-DB approach (that is actually in the HTML5 spec). This might be enough, depending on your ultimate goal.

对于完整的,传统的数据库支持,你必须编写一个web界面...

For full, traditional, DB support, you will have to write a web interface...


  1. 您可以在任何机器上使用 XAMPP

使用 GM_xmlhttpRequest将您的数据从Greasemonkey脚本发送到网络应用程序,如下所示:

var myData      = {strVar: 'Hiya!', intVar: 777, etc: 'et cetera'};
var DataForDB   = JSON.stringify (myData);

GM_xmlhttpRequest ( {
    method:     "POST",
    url:        "http://localhost/YourDir/LogMyData.php",
    data:       DataForDB,
    headers:    {"Content-Type": "application/json"}
} )


PHP网页会撷取这些资料:

A PHP webpage would extract the data like so:

$myData = json_decode($HTTP_RAW_POST_DATA);
print_r ($myData);


  • 然后,网页与mySQL进行交互,返回任何所需的值GM script。

  • The web page then interacts with mySQL as you see fit, returning any desired values to the GM script.

    这篇关于我可以在FireFox中执行MySQL SQL语句吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆