使用基础接口操作数据库增删改查示例代码

rambo 4个月前 阅读:960 评论:0
  //写入数据--  adddata() {    wx.request({      ...
  //写入数据--
  adddata() {
    wx.request({
      url: 'https://cloud.huaxio.cn/userfile/sqlapi/getapi.php',
      data: {
        apiname: '', //接口名称
        apipswd: '', //接口密码
        getysql: '' //执行语句
      },
      method: 'post',
      header: {
        "Content-Type": "application/x-www-form-urlencoded"
      },
      dataType: 'json',
      responseType: 'text',
      success: (res) => {
        console.log(res.data)
      },
      fail: () => {},
      complete: () => {}
    })
  },
  //删除数据
  deldata() {
    wx.request({
      url: 'https://cloud.huaxio.cn/userfile/sqlapi/getapi.php',
      data: {
        apiname: '', //接口名称
        apipswd: '', //接口密码
        getysql: '' //执行语句
      },
      method: 'post',
      header: {
        "Content-Type": "application/x-www-form-urlencoded"
      },
      dataType: 'json',
      responseType: 'text',
      success: (res) => {
        console.log(res.data)
      },
      fail: () => {},
      complete: () => {}
    })
  },
  //更新数据
  unpdata() {
    wx.request({
      url: 'https://cloud.huaxio.cn/userfile/sqlapi/getapi.php',
      data: {
        apiname: '', //接口名称
        apipswd: '', //接口密码
        getysql: '' //执行语句
      },
      method: 'post',
      header: {
        "Content-Type": "application/x-www-form-urlencoded"
      },
      dataType: 'json',
      responseType: 'text',
      success: (res) => {
        console.log(res.data)
      },
      fail: () => {},
      complete: () => {}
    })
  },
  //查询数据
  secdata() {
    wx.request({
      url: 'https://cloud.huaxio.cn/userfile/sqlapi/getapi.php',
      data: {
        apiname: '', //接口名称
        apipswd: '', //接口密码
        getysql: '' //执行语句
      },
      method: 'post',
      header: {
        "Content-Type": "application/x-www-form-urlencoded"
      },
      dataType: 'json',
      responseType: 'text',
      success: (res) => {
        // console.log(res.data.result[2]['data1'])
        console.log(res.data)
      },
      fail: () => {},
      complete: () => {}
    })
  },


热门文章
标签列表