PHPackages                             retamayo/absl - 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. retamayo/absl

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

retamayo/absl
=============

Absl (PHP Database Abstraction Library) is a lightweight and flexible library designed to simplify database operations in PHP applications. It provides a convenient interface for interacting with various database systems using the PHP Data Objects (PDO) extension.

v1.1.0(2y ago)2171MITPHPPHP 7.4.33|^8.0

Since Jun 25Pushed 2y ago1 watchersCompare

[ Source](https://github.com/RE-Tamayo/absl)[ Packagist](https://packagist.org/packages/retamayo/absl)[ RSS](/packages/retamayo-absl/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)DependenciesVersions (4)Used By (0)

Absl - PHP Database Abstraction Library
=======================================

[](#absl---php-database-abstraction-library)

> The docs are live at .

Absl (PHP Database Abstraction Library) is a lightweight and flexible library designed to simplify database operations in PHP applications. It provides a convenient interface for interacting with various database systems using the PHP Data Objects (PDO) extension.

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

[](#table-of-contents)

1. Installation
2. Connecting to a Database
3. Defining Tables
4. Working with Tables
5. Retrieving Data
6. Data Manipulation
7. Authentication
8. Data Validation
9. Data Sanitization
10. Conclusion

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

[](#installation)

To use Absl in your PHP project, you can install it via Composer, which is a dependency management tool for PHP. Follow the steps below to install Absl using Composer:

1. Ensure you have Composer installed on your system. If you don't have Composer installed, you can download and install it by following the instructions on the official Composer website:
2. Once Composer is installed, navigate to your project directory in the command-line interface.
3. Run the following command in your project directory to install Absl and its dependencies:

```
composer require retamayo/absl
```

Composer will download the Absl library and its required dependencies and set up the autoloading for you. After the installation is complete, you can include the Composer autoloader in your PHP files to start using Absl:

```
require 'vendor/autoload.php';
```

Make sure to adjust the path to the autoload.php file based on your project structure. That's it! You have successfully installed Absl in your PHP project using Composer. You can now start using Absl's features and methods by referencing the library in your code.

Connecting to a Database
------------------------

[](#connecting-to-a-database)

Before you can start using Absl, you need to establish a connection to your database. Absl uses the PDO extension, which supports a wide range of database systems such as MySQL, PostgreSQL, SQLite, and more.

To connect to a database, create a new PDO object and pass it to the Absl constructor:

```
$host = 'localhost';
$dbName = 'your_database_name';
$username = 'your_username';
$password = 'your_password';

try {
    $pdo = new PDO("mysql:host=$host;dbname=$dbName", $username, $password);
    $absl = new Absl($pdo);
} catch (PDOException $e) {
    echo "Database connection failed: " . $e->getMessage();
    // Handle the connection error gracefully
}
```

Make sure to replace the placeholders ($host, $dbName, $username, $password) with your actual database credentials.

Defining Tables
---------------

[](#defining-tables)

Absl allows you to define tables by specifying the table name, primary key, and column details. This step is essential to inform Absl about the structure of your database tables.

To define a table, use the defineTable() method:

```
$tableName = 'users';
$primaryKey = 'id';
$columns = ['column1', 'column2', 'column3'];

$absl->defineTable($tableName, $primaryKey, $columns);
```

Repeat the defineTable() method for each table in your database.

Working with Tables
-------------------

[](#working-with-tables)

To perform database operations on a specific table, you need to select the table first using the useTable() method:

```
$tableName = 'users';

try {
    $absl->useTable($tableName);
} catch (Exception $e) {
    echo "Table selection failed: " . $e->getMessage();
    // Handle the error gracefully
}
```

Once a table is selected, Absl will use the defined table structure for subsequent operations.

Retrieving Data
---------------

[](#retrieving-data)

Absl provides several methods to retrieve data from the selected table:

To fetch all records from the table:

```
$records = $absl->list();
```

You can also specify which columns to fetch:

```
$records = $absl->list(['column1', 'column2']);
```

To fetch a single record based on a unique column:

```
$record = $absl->fetch(['column1', 'column2'], 'unique_column_name', 'unique_column_value');
```

To fetch all records from the table in JSON format:

```
$jsonData = $absl->listJSON();
```

To fetch a single record based on a unique column in JSON format:

```
$record = $absl->fetchJSON(['column1', 'column2'], 'unique_column_name', 'unique_column_value');
```

Data Manipulation
-----------------

[](#data-manipulation)

Absl simplifies data manipulation operations such as creating new records, updating existing records, and deleting records.

To create a new record:

```
$data = [
    'name' => 'John Doe',
    'email' => 'john@example.com',
    // Set other column values as needed
];

$newRecordId = $absl->create($data);
```

Note: When creating a new record with a password make sure to hash it and use password\_hash() method and use PASSWORD\_DEFAULT as the hashing algorithm, otherwise the authentication() method might not work as expected.

To update an existing record:

```
$where = 'id';
$whereValue = '1';
$data = [
    'name' => 'Jane Doe',
    'email' => 'jane@example.com',
    // Update other column values as needed
];

$updatedRows = $absl->update($data, $where, $whereValue);
```

To delete a record:

```
$where = 'id';
$whereValue = '1';
$deletedRows = $absl->delete($where, $whereValue);
```

Note : The create, update, and delete methods returns true or false depending on the status of the operation.

Authentication Absl provides an authenticate() method to validate user credentials stored in the database. You can use this method to implement user authentication functionality in your PHP application.

```
$username = 'john@example.com';
$password = 'password123';

if ($absl->authenticate(['column_name_of_username_or_email' => $username, 'column_name_of_password' => $password])) {
    // Authentication successful
} else {
    // Authentication failed
}
```

Make sure to store passwords securely by using techniques like hashing and salting.

Note: When passing credentials array to the authenticate function make sure to put the password index last.

Data Validation
---------------

[](#data-validation)

Absl includes a checkDuplicate() method to validate the uniqueness of values in a specified column. This can be helpful for ensuring data integrity and preventing duplicate entries in your database.

```
$columnName = 'email';
$columnValue = 'john@example.com';

if ($absl->checkDuplicate($columnName, $columnValue)) {
    // Value is already present in the column
} else {
    // Value is unique
}
```

Data Sanitization
-----------------

[](#data-sanitization)

Absl automatically sanitizes input values and prevent common security vulnerabilities such as SQL injection and cross-site scripting (XSS).

Conclusion
----------

[](#conclusion)

This documentation provides a basic overview of how to use Absl, a PHP database abstraction library, to simplify database operations in your PHP applications. You can explore the library further to discover additional features and advanced usage scenarios.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 94.1% 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 ~29 days

Total

3

Last Release

993d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2bdd34a26d70bdb8f53d0dc3a1e576dda36307827f86a8a70c0e1673c57ba196?d=identicon)[retamayo](/maintainers/retamayo)

---

Top Contributors

[![retamayo](https://avatars.githubusercontent.com/u/67304955?v=4)](https://github.com/retamayo "retamayo (16 commits)")[![Lawondyss](https://avatars.githubusercontent.com/u/272130?v=4)](https://github.com/Lawondyss "Lawondyss (1 commits)")

### Embed Badge

![Health badge](/badges/retamayo-absl/health.svg)

```
[![Health](https://phpackages.com/badges/retamayo-absl/health.svg)](https://phpackages.com/packages/retamayo-absl)
```

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M546](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

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