PHPackages                             migliori/power-lite-pdo - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. migliori/power-lite-pdo

ActiveLibrary[Database &amp; ORM](/categories/database)

migliori/power-lite-pdo
=======================

PowerLitePdo is a PDO wrapper that provides a simple and powerful way to interact with a database.

1.1.1(1y ago)14821GPL-3.0-or-laterPHPPHP &gt;=7.4CI failing

Since Aug 9Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/migliori/power-lite-pdo)[ Packagist](https://packagist.org/packages/migliori/power-lite-pdo)[ Docs](https://www.powerlitepdo.com/)[ RSS](/packages/migliori-power-lite-pdo/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (4)Versions (4)Used By (0)

PowerLite PDO
=============

[](#powerlite-pdo)

[![Static Badge](https://camo.githubusercontent.com/50253820e667ebcce325162d9a3d1bde05baf1f58f5be6e8ddd5ebc3ce86a021/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f706870253230372e342b2d6661666166613f6c6f676f3d706870)](https://camo.githubusercontent.com/50253820e667ebcce325162d9a3d1bde05baf1f58f5be6e8ddd5ebc3ce86a021/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f706870253230372e342b2d6661666166613f6c6f676f3d706870) [![GPLv3 License](https://camo.githubusercontent.com/da9c3abfd62c32a94031c3a382cb7c85dbd4cede411416837adfe6b8fda05ba1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d47504c25323076332d79656c6c6f772e737667)](https://opensource.org/licenses/) [![GitHub Release](https://camo.githubusercontent.com/e4851b5a7dcccd54c5e8cc8af3ff8c3524a7db60053d076ccf6480ff47b3b238/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f6d69676c696f72692f706f7765722d6c6974652d70646f)](https://camo.githubusercontent.com/e4851b5a7dcccd54c5e8cc8af3ff8c3524a7db60053d076ccf6480ff47b3b238/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f6d69676c696f72692f706f7765722d6c6974652d70646f)

[PowerLite PDO](https://www.powerlitepdo.com) is a lightweight, powerful PHP library that provides a simple and efficient way to interact with databases using PHP Data Objects (PDO). It supports multiple database drivers and includes features like easy connection management, query execution, result handling and pagination.

[![PowerLite PDO](https://camo.githubusercontent.com/8b42cdc66ebb1efaa3c60445e30345e85765e48084851caa91ead1b536ee7ea0/68747470733a2f2f7777772e706f7765726c69746570646f2e636f6d2f696d616765732f706f7765726c6974652d70646f2d6c6f676f2d686f72697a6f6e74616c2e37376264396434623332306566343734376336323565373239613735656334622e706e67)](https://www.powerlitepdo.com)

Table of Contents
-----------------

[](#table-of-contents)

- [Features](#features)
- [Requirements](#requirements)
- [Documentation](#documentation)
- [Installation](#installation)
- [Configuration](#configuration)
- [Usage/Examples](#usageexamples)
- [Running Tests](#running-tests)
- [Contributing](#contributing)
- [License](#license)

Features
--------

[](#features)

- **Containerized Connections:** The containers are used to connect your database and handle the configuration and dependencies seamlessly.
- **Db &amp; QueryBuilder Methods:** Execute SQL queries and retrieve results using Db methods or the fluent QueryBuilder.
- **Efficient Result Handling:** Fetch single row, all rows, or specific column's value with dedicated methods.
- **Comprehensive Database Operations:** Provides a wide range of methods for diverse database interactions.
- **Pagination Support:** Handle paginated results effortlessly with the Pagination class.
- **Error Management:** User-friendly handling of database errors and exceptions.
- **Debug Mode:** Provides detailed information about the requests for debugging purposes.
- **Prepared Statements:** Support for prepared statements to prevent SQL injection attacks.
- **Transaction Control:** Manage database transactions with methods to start, commit, and rollback.
- **High Code Quality Standards:** The code follows best practices and coding standards.

Requirements
------------

[](#requirements)

PHP ^7.4, PHP 8.x

Documentation
-------------

[](#documentation)

The documentation for PowerLite PDO is available on the [PowerLite PDO website](https://www.powerlitepdo.com).

In addition to the documentation, a PHPDoc is also available [here](doc/index.html) for more detailed information about the classes, methods, and their parameters.

Installation
------------

[](#installation)

Clone / download or install with Composer

```
composer require migliori/power-lite-pdo
```

Configuration
-------------

[](#configuration)

Open `src/connection.php` in your code editor and replace the constant's values with your database connection settings (DB\_HOST, DB\_NAME, DB\_USER, DB\_PASS, DB\_PORT, DB\_CHARSET).

### Security concerns

[](#security-concerns)

For enhanced safety, store the file outside of your web server's document root (the directory that is served to the internet) and change the path accordingly in the configuration file (`src/config.php`). This prevents the file from being directly accessible via a URL.

Usage/Examples
--------------

[](#usageexamples)

### Select records using the main Db class

[](#select-records-using-the-main-db-class)

1. Include the bootstrap file and get the Db instance from the container:

    ```
    use Migliori\PowerLitePdo\Db;

    // Build the container and connect to the database
    $container = require_once __DIR__ . '/vendor/migliori/power-lite-pdo/src/bootstrap.php';
    $db = $container->get(Db::class);
    ```
2. Use the select method from the Db class to select some records:

    ```
    $from = 'users'; // The table name
    $fields = ['id', 'username', 'email']; // The columns you want to select
    $where = ['status' => 'active']; // The conditions for the WHERE clause

    $db->select($from, $fields, $where);
    ```
3. Fetch the selected records one by one:

    ```
    while ($record = $db->fetch()) {
        echo $record->id . ', ' . $record->username . ', ' . $record->email . "\n";
    }
    ```

### Select records using the fluent QueryBuilder

[](#select-records-using-the-fluent-querybuilder)

1. Include the bootstrap file and get the QueryBuilder instance from the container:

    ```
    use Migliori\PowerLitePdo\Query\QueryBuilder;

    // Build the container and connect to the database
    $container = require_once __DIR__ . '/vendor/migliori/power-lite-pdo/src/bootstrap.php';
    $queryBuilder = $container->get(QueryBuilder::class);
    ```
2. Use the QueryBuilder to select some records:

    ```
    $queryBuilder->select(['id', 'username', 'email'])->from('users')->where(['status' => 'active'])->execute();
    ```
3. Fetch the selected records one by one:

    ```
    while ($record = $queryBuilder->fetch()) {
        echo $record->id . ', ' . $record->username . ', ' . $record->email . "\n";
    }
    ```

### Select records with Pagination

[](#select-records-with-pagination)

1. Include the bootstrap file and get the Pagination instance from the container:

    ```
    use Migliori\PowerLitePdo\Pagination;

    // Build the container and connect to the database
    $container = require_once __DIR__ . '/vendor/migliori/power-lite-pdo/src/bootstrap.php';
    $pagination = $container->get(Pagination::class);
    ```
2. Select some records:

    ```
    $from = 'users'; // The table name
    $fields = ['id', 'username', 'email']; // The columns you want to select
    $where = ['status' => 'active']; // The conditions for the WHERE clause

    $pagination->select($from, $fields, $where);
    ```
3. Fetch the selected records one by one:

    ```
    while ($record = $pagination->fetch()) {
        echo $record->id . ', ' . $record->username . ', ' . $record->email . "\n";
    }
    ```
4. Display the pagination:

    ```
    $url = '/users'; // The URL for the pagination links
    echo $pagination->pagine($url);
    ```

Running Tests
-------------

[](#running-tests)

To run tests, run the following command

```
php ./vendor/bin/phpunit test
```

Dependencies
------------

[](#dependencies)

- **Composer:** A dependency management tool for PHP.
- **PHP-DI:** A dependency injection container for PHP.
- **PDO:** The PHP Data Objects extension for accessing databases.
- **Database Drivers:** The specific drivers for the databases you want to connect to (e.g., MySQL, PostgreSQL, Oracle, Firebird, ...).

Dev Dependencies
----------------

[](#dev-dependencies)

- **PHPUnit:** A testing framework for unit testing PHP code.
- **PHPStan:** A static analysis tool that helps find bugs in PHP code.
- **PHP CodeSniffer:** A set of rules to ensure that PHP code follows coding standards.

Contributing
------------

[](#contributing)

Contributions are always welcome!

Please contact us for any improvement suggestions or send your pull requests

License
-------

[](#license)

[GNU General Public License v3.0](https://choosealicense.com/licenses/gpl-3.0/)

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance59

Moderate activity, may be stable

Popularity18

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~25 days

Total

3

Last Release

591d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/82cd171f848f6e6fc792344b87070bebaee163b5719cc7166d0ebf1fcfff2b58?d=identicon)[migli](/maintainers/migli)

---

Top Contributors

[![migliori](https://avatars.githubusercontent.com/u/7558100?v=4)](https://github.com/migliori "migliori (17 commits)")

---

Tags

databasedbalfirebirdmysqlocipdopdo-wrapperpgsqlphp-librarydatabasepdowrapper

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Type Coverage Yes

### Embed Badge

![Health badge](/badges/migliori-power-lite-pdo/health.svg)

```
[![Health](https://phpackages.com/badges/migliori-power-lite-pdo/health.svg)](https://phpackages.com/packages/migliori-power-lite-pdo)
```

###  Alternatives

[doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.

9.7k578.4M5.6k](/packages/doctrine-dbal)[ifsnop/mysqldump-php

PHP version of mysqldump cli that comes with MySQL

1.3k5.5M69](/packages/ifsnop-mysqldump-php)[nette/database

💾 Nette Database: layer with a familiar PDO-like API but much more powerful. Building queries, advanced joins, drivers for MySQL, PostgreSQL, SQLite, MS SQL Server and Oracle.

5656.7M234](/packages/nette-database)[dibi/dibi

Dibi is Database Abstraction Library for PHP

5013.8M120](/packages/dibi-dibi)[aura/sqlquery

Object-oriented query builders for MySQL, Postgres, SQLite, and SQLServer; can be used with any database connection library.

4572.9M34](/packages/aura-sqlquery)[envms/fluentpdo

FluentPDO is a quick and light PHP library for rapid query building. It features a smart join builder, which automatically creates table joins.

925511.7k13](/packages/envms-fluentpdo)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
