项目不会在SQL表android的末尾插入


Items does not get inserted at end of SQL table android

我正在发送数据从我的android应用程序被添加到在线数据库。但是数据并不存储在表的末尾。它被存储在表中的随机位置。我该如何避免这种情况?这是我的PHP代码。

<?php
error_reporting(E_ALL ^ E_DEPRECATED);
$response = array();
$title = $_POST['Title'];
$time = $_POST['Time'];
$posted= $_POST['posted'];


require_once __DIR__ . '/db_connect.php';

$db = new DB_CONNECT();

$result = mysql_query("INSERT INTO mukul(Title, Time, posted) VALUES('$title', '$time', '$posted')");
if ($result) {
    $response["success"] = 1;
    $response["message"] = "Product successfully created.";

    echo json_encode($response);
} else {
    $response["success"] = 0;
    $response["message"] = "Oops! An error occurred.";

    echo json_encode($response);
}
?>  

在关系数据库中没有"表的结尾"这样的东西。数据以对数据库最方便的顺序存储(受表上索引的影响)。所以你问的根本不是bug,而是预期的行为。只要在获取数据时使用ORDER BY子句就可以确保您想要的顺序。与您可能认为的相反(我不得不猜测,因为问题有点模糊),执行ORDER BY并不是一个缓慢的操作,特别是如果您在排序列上有一个索引。

如果你需要索引方面的帮助,可以参考MySQL手册