What are the best practices for handling multiple entries with the same timestamp in a PHP script when using LIMIT and ORDER BY?

When handling multiple entries with the same timestamp in a PHP script using LIMIT and ORDER BY, it's important to also include a secondary sorting column to ensure consistent results. One common approach is to add an additional column, such as an auto-incrementing ID, to the ORDER BY clause to break ties between entries with the same timestamp.

// Query to retrieve data with multiple entries having the same timestamp
$query = "SELECT * FROM table_name ORDER BY timestamp_column, id_column LIMIT 10";

// Execute the query and fetch the results
$result = $pdo->query($query);

// Loop through the results
foreach ($result as $row) {
    // Process each row as needed
}