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);
      });
    
    });
    
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器