Database connections, SQL execution, and transaction helpers for Switon Framework

Maintainers

Package info

github.com/switon-php/db

Documentation

pkg:composer/switon/db

Statistics

Installs: 7

Dependents: 4

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-05-09 23:36 UTC

This package is auto-updated.

Last update: 2026-05-10 02:46:18 UTC


README

Database connections, SQL execution, and transaction helpers for Switon Framework.

Installation

composer require switon/db

Requirements: PHP 8.3+, ext-pdo, and a PDO driver extension such as pdo_mysql, pdo_pgsql, pdo_sqlite, or pdo_sqlsrv

Quick Start

use Switon\Core\Attribute\Autowired;
use Switon\Db\ClientInterface;

class UserRepository
{
    #[Autowired] protected ClientInterface $db;

    public function findById(int $id): ?array
    {
        $rows = $this->db->fetchAll(
            'SELECT * FROM users WHERE id = :id LIMIT 1',
            ['id' => $id],
        );

        return $rows[0] ?? null;
    }
}

Docs: https://docs.switon.dev/latest/db

License

MIT.