简体   繁体   English

如何将Unity Mobile App连接到Azure SQL数据库?

[英]How to connect Unity Mobile App to Azure SQL Database?

im developing an app in Unity for Android and iOS. 我在Android和iOS版Unity中开发了一个应用。

The app will prompt the user to fill out a survey on the first use, I need the data from that survey to be stored in a database for analytics and I decided it would be Azure. 该应用程序将提示用户首次使用时填写调查,我需要将该调查中的数据存储在数据库中进行分析,然后我决定将其设为Azure。

What Azure services will I need to implement this functionality? 要实现此功能,我需要哪些Azure服务? I need it to be as little and economical as possible as they are the only data I will store and the app is small. 我需要它尽可能的少和经济,因为它们是我将要存储的唯一数据并且应用程序很小。

And from the Azure services needed, how do you implement that functionality? 从所需的Azure服务中,如何实现该功能? Any tutorials for beginners? 有适合初学者的教程吗?

I also have basic knowledge of Azure. 我也有Azure的基础知识。

Thank you very much! 非常感谢你! I hope you can help me. 我希望你能帮助我。

You will need to use a POST method. 您将需要使用POST方法。

Create a PHP file to connect to your database and then use your code to send the data. 创建一个PHP文件以连接到数据库,然后使用您的代码发送数据。

example C#: 示例C#:

public void CreateUser(string username, string firstName, string lastName, string email, string phoneNumber)
    {
            WWWForm form = new WWWForm();
            form.AddField("userNamePost", username);
            form.AddField("firstNamePost", firstName);
            form.AddField("lastNamePost", lastName);
            form.AddField("phoneNumberPost", phoneNumber);
            form.AddField("emailPost", email);
            WWW www = new WWW("URL of the PHP file", form);
    }

example PHP: 示例PHP:

<?php
$servername = "localhost";
$server_username = "root";
$server_password = "";
$dbName = "databaseName";

$userName = $_POST['userNamePost'];
$firstName = $_POST['firstNamePost'];
$lastName = $_POST['lastNamePost'];
$phoneNumber = $_POST['phoneNumberPost'];
$emailAddress = $_POST['emailPost'];

$conn = new mysqli($servername, $server_username, $server_password, $dbName);

if(!$conn)
{
    die("Connection Failed" .mysqli_connect_error());
}
else
{
    echo "Connected";
}
$sql = "INSERT INTO table (all field names) VALUES ('".$userName."','".$firstName."','".$lastName."','".$phoneNumber."','".$emailAddress."')";
$result = mysqli_query($conn, $sql);
?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何连接windows phone app使用存储在sql azure中的数据库 - How to connect windows phone app to use database stored in sql azure Blazor C# App如何连接到Azure Z9778840A0100CB30C982876741B0数据库? 苹果系统 - How to connect Blazor C# App to Azure SQL Database? MacOS 如何使用已在Azure中注册的应用程序使用实体框架数据库第一种方法连接到Azure SQL DB - How to connect to Azure SQL DB using entity framework database first approach using already registered app in Azure 将Unity App连接到mySQL数据库 - Connect Unity App to mySQL database 将Azure移动应用程序服务与现有SQL数据库一起使用 - Using Azure Mobile App service with existing SQL database 如何从 Azure 应用服务中托管的 API 应用程序连接到 AWS 中托管的 SQL 数据库 - How to connect to SQL database hosted in AWS from API application hosted in Azure App Service 将Windows Phone 8.1 Store应用连接到现有的Azure SQL数据库 - Connect a Windows Phone 8.1 Store App to an Existing Azure SQL Database 如何将SQL Server数据库与Unity3D连接? - How to connect SQL Server Database with Unity3D? 如何从Unity连接到数据库 - How to connect to database from Unity 如何将SQL Server与Unity连接? - How to connect SQL Server with Unity?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM