duanjia9577 2017-08-06 10:13
浏览 292

将我的React应用程序连接到PHP服务器上的MySQL数据库

I am new to working with data bases. I have a react app that I would like to connect to a MySQL database. The server is not mine but given by a web provider (strato), using PHP.

Is it generally possible to GET and PUT data via react (meaning javascript) to this data base in a way that I normally work with ajax and a restful API?

I really hope this question provides enough information for an answer :)

  • 写回答

1条回答 默认 最新

  • doudou5421 2017-08-06 12:03
    关注

    Here's a code example from https://github.com/numtel/reactive-mysql-example, file index.js. Have a look at that file and settings.js to see how to set up the connection.

    var results = liveDb.select('select * from players order by score desc', [ {
      table: 'players'
    } ]).on('update', function(diff, data){
    
      var msg = JSON.stringify({
        type: 'diff',
        data: diff
      });
    
      // Send change to all clients
      connected.forEach(function(conn){
        conn.write(msg);
      });
    
    });
    
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度