Download the PHP package retamayo/absl without Composer
On this page you can find all versions of the php package retamayo/absl. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download retamayo/absl
More information about retamayo/absl
Files in retamayo/absl
Package absl
Short Description 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.
License MIT
Informations about the package absl
Absl - PHP Database Abstraction Library
The docs are live at https://absl-docs.vercel.app.
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
- Installation
- Connecting to a Database
- Defining Tables
- Working with Tables
- Retrieving Data
- Data Manipulation
- Authentication
- Data Validation
- Data Sanitization
- Conclusion
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:
- 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: https://getcomposer.org/download/
- Once Composer is installed, navigate to your project directory in the command-line interface.
- Run the following command in your project directory to install Absl and its dependencies:
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:
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
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:
Make sure to replace the placeholders ($host, $dbName, $username, $password) with your actual database credentials.
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:
Repeat the defineTable() method for each table in your database.
Working with Tables
To perform database operations on a specific table, you need to select the table first using the useTable() method:
Once a table is selected, Absl will use the defined table structure for subsequent operations.
Retrieving Data
Absl provides several methods to retrieve data from the selected table:
To fetch all records from the table:
You can also specify which columns to fetch:
To fetch a single record based on a unique column:
To fetch all records from the table in JSON format:
To fetch a single record based on a unique column in JSON format:
Data Manipulation
Absl simplifies data manipulation operations such as creating new records, updating existing records, and deleting records.
To create a new record:
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:
To delete a record:
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.
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
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.
Data Sanitization
Absl automatically sanitizes input values and prevent common security vulnerabilities such as SQL injection and cross-site scripting (XSS).
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.
All versions of absl with dependencies
ext-mbstring Version *
ext-iconv Version *
ext-pdo Version *
ext-json Version *
ext-curl Version *
ext-simplexml Version *