1. 程式人生 > >微信小程式開發:連結騰訊雲小程式伺服器資料庫

微信小程式開發:連結騰訊雲小程式伺服器資料庫

1.  連線php檔案書寫

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

use QCloud_WeApp_SDK\Mysql\Mysql as DB;   // 引入DB

class Tt extends CI_Controller {
    public function index() {
        $this->json([
            'code' => 0,
            'data' => [
                'msg' => 'Hello World我是Tt檔案。。。。。'
            ]
        ]);
    }

    public function test(){
      echo "Look at this :hi it's me!";
    }

    public function cha(){
      // ehco '查詢';
      $row = DB::select('nn',['*'],'name = "bnc"'); //查表名為nn的表裡名字是bnc的資料
      
      $this->json([
        'data' => $row
      ]);
    }
}

2.成功查到資料並輸出輸出 

https://fmajp3wr.qcloud.la/weapp/tt/cha  是小程式騰訊雲分配的開發環境的測試域名,生產環境下另行更換。

後臺資料庫: