框架用多了已经石乐志了,以及不记得原生的形状了
写个简单的sql操作回复下
先链接数据库
$link = new mysqli('localhost', 'tr_data_u', 'wdnmd112', 'tr_data');
mysqli_set_charset($link, 'utf8');
if ($link->connect_error) {
die("连接失败: " . $conn->connect_error);
}
获取url参数
$operation = $_GET['operation'];
$server = $_GET['qq'];
$username = $_GET['username'];
sql预处理语句
$sql = "INSERT INTO user_data (" . $server . ",qq) VALUES (?,?)";
sql执行
$stmt = $link->prepare($sql);
$stmt->bind_param('ss', $username, $qq);
$stmt->execute();
执行完成后的消息
$msg='操作成功'
返回json数据
header('Content-Type:application/json;');
$str = array(
'status' => '200',
'msg' => $msg,
'data' => [$data]
);
$jsonencode = json_encode($str);
echo $jsonencode;
逻辑就不放了,更丢人