How does PDO handle line breaks compared to mysqli in PHP?

When handling line breaks in PHP with PDO, the data is automatically escaped and properly handled when inserting or retrieving from the database. However, with mysqli, you need to manually escape special characters like line breaks using the mysqli_real_escape_string() function before inserting data into the database.

// Using PDO
$pdo = new PDO("mysql:host=localhost;dbname=mydatabase", "username", "password");
$stmt = $pdo->prepare("INSERT INTO mytable (mycolumn) VALUES (:data)");
$data = "This is a string with\na line break";
$stmt->bindParam(':data', $data);
$stmt->execute();

// Using mysqli
$mysqli = new mysqli("localhost", "username", "password", "mydatabase");
$data = "This is a string with\na line break";
$data = $mysqli->real_escape_string($data);
$mysqli->query("INSERT INTO mytable (mycolumn) VALUES ('$data')");