aksined_by/pdoreconnect

A PDO reconnection library

v0.0.2 2024-07-28 15:07 UTC

This package is auto-updated.

Last update: 2025-02-28 14:30:10 UTC


README

Latest Stable Version Total Downloads License

Description

The PDO Reconnect Library is a PHP library that extends PDO functionality by adding automatic reconnection capability. This is particularly useful in long-running scripts where the database connection might be lost and needs to be reestablished seamlessly. A great solution for Consumers and demon-scripts

Features

  • Automatic reconnection on connection loss
  • Easy to integrate and use
  • Compatible with various databases supported by PDO

Requirements

  • PHP 7.4 or higher

Installation

You can install the library via Composer:

composer require aksined_by/pdoreconnect

Usage

Here is a basic example of how to use the PDO Reconnect Library:

require 'vendor/autoload.php';

use AksinedBy\PdoReconnect\AppPdo;

$dsn = 'mysql:host=localhost;dbname=testdb';
$username = 'yourusername';
$password = 'yourpassword';

$pdo = new AppPdo($dsn, $username, $password);
$stmt = $pdo->prepare('SELECT * FROM your_table');
$stmt->execute();
$results = $stmt->fetchAll();
print_r($results);

Testing

To run the tests, you need to have PHPUnit installed. You can run the tests using the following command:

vendor/bin/phpunit

Contributing

Contributions are welcome! If you find any issues or have suggestions for improvements, feel free to open an issue or submit a pull request. Please follow the established coding standards and write tests for any new features or bug fixes.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Contact

For any questions or inquiries, you can reach out to aksined.by@gmail.com.