What are the differences between PHP 5.3 and PHP 7 in terms of database connectivity and querying?

PHP 7 introduced several improvements in terms of database connectivity and querying compared to PHP 5.3. Some of the key differences include improved performance, better error handling, and support for new features like the null coalescing operator and scalar type declarations.

// PHP 7 code for connecting to a MySQL database using PDO
$host = 'localhost';
$dbname = 'database';
$username = 'root';
$password = '';

try {
    $pdo = new PDO("mysql:host=$host;dbname=$dbname", $username, $password);
    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    echo "Connected successfully";
} catch(PDOException $e) {
    echo "Connection failed: " . $e->getMessage();
}