How does PDO Prepared Statements handle LIMIT in PHP queries?

When using PDO Prepared Statements in PHP queries, the LIMIT clause can be included in the SQL query string, but the actual value for the LIMIT should be bound as a parameter in the execute() method. This helps prevent SQL injection attacks and ensures proper escaping of the input.

// Example code for using PDO Prepared Statements with LIMIT in PHP queries
$limit = 10;
$offset = 0;

$sql = "SELECT * FROM table_name LIMIT :limit OFFSET :offset";
$stmt = $pdo->prepare($sql);
$stmt->bindParam(':limit', $limit, PDO::PARAM_INT);
$stmt->bindParam(':offset', $offset, PDO::PARAM_INT);
$stmt->execute();

// Fetch results
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);