Skip to content

alxarafe/resource-pdo

Repository files navigation

alxarafe/resource-pdo

PHP Version CI Tests Static Analysis PRs Welcome

Native PDO adapter for alxarafe/resource-controller.

Implements RepositoryContract, QueryContract, and TransactionContract using pure PHP PDO, without relying on ORMs or heavy database libraries.

Ecosystem

Package Purpose Status
resource-controller Core CRUD engine + UI components ✅ Stable
resource-eloquent Eloquent ORM adapter ✅ Stable
resource-pdo Native PDO adapter ✅ Stable
resource-blade Blade template renderer adapter ✅ Stable
resource-twig Twig template renderer adapter ✅ Stable
resource-html Pure PHP/HTML template renderer adapter ✅ Stable

Installation

composer require alxarafe/resource-pdo

Usage

use Alxarafe\ResourceController\AbstractResourceController;
use Alxarafe\ResourceController\Contracts\RepositoryContract;
use Alxarafe\ResourceController\Contracts\TransactionContract;
use Alxarafe\ResourcePdo\PdoRepository;
use Alxarafe\ResourcePdo\PdoTransaction;

class UsersController extends AbstractResourceController
{
    private \PDO $pdo;

    public function __construct(\PDO $pdo) {
        $this->pdo = $pdo;
    }

    protected function getRepository(string $tabId = 'default'): RepositoryContract
    {
        return new PdoRepository($this->pdo, 'users', 'id');
    }

    protected function getTransaction(): TransactionContract
    {
        return new PdoTransaction($this->pdo);
    }
}

Features

  • Dependency-free database access using native PHP \PDO.
  • Fast, secure, and prepared statements out-of-the-box.
  • Seamless compatibility with alxarafe/resource-controller configuration array definitions.

License

GPL-3.0-or-later

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors