目前,我通过向服务器的php文件发送请求,使用下面的sql查询从db检索所有数据。
我需要在php文件中添加一个变量作为这个mysql请求的条件,例如carName="Somecar“和slice=3。我如何将这些条件添加到我的请求中,并继续使用下面的UnityWebRequest.kHttpVerbGET和ToFileDownloadHandler?
当前的统一请求:
Debug.Log("Retrieving existing data from server.");
UnityWebRequest myWebRequest = new UnityWebRequest(path, UnityWebRequest.kHttpVerbGET);
myWebRequest.downloadHandler = new ToFileDownloadHandler(new byte[64 * 1024], savePathWithFileName);
yield return myWebRequest.SendWebRequest();
和php:
$stmt = $conn->prepare("SELECT id, carName, thisCarImg, i_width, i_heigth, i_depth, b_width, b_heigth, b_depth, f_depth, m_width, m_heigth, i_date, slope, slice, slopeName, sliceName FROM $myTable")
$stmt->execute();
我认为最好的方法是添加php作为附加标记,尽管问题是如何将表单添加到Unity的查询中--使用php中收到的表单是另一回事。
发布于 2020-01-21 10:01:42
您必须在路径中添加参数。
例如:sample.php?Somecar=122&slice=1
通过这种方式,您可以在GET请求时在API调用PHP时实现这种统一输入,如果您使用POST,则可以使用WWWForm类。
https://stackoverflow.com/questions/59824454
复制相似问题