Download the PHP package ucscode/pairs without Composer
On this page you can find all versions of the php package ucscode/pairs. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ucscode/pairs
More information about ucscode/pairs
Files in ucscode/pairs
Package pairs
Short Description PHP tool designed to efficiently store and retrieve key-value pairs in a database.
License MIT
Informations about the package pairs
Pairs Library Documentation
The Pairs library is a PHP tool designed to efficiently store and retrieve key-value pairs in a database. It provides a simple and flexible interface for managing data in a relational database. Below is a comprehensive guide on how to use the library.
Dedication
This library was initially a part of User Synthetics project but was extracted to become a standalone project.
Table of Contents
- Introduction
- Features
- Requirements
- Installation
- Usage
- Initialization
- Set a Key-Value Pair
- Retrieve a Value
- Remove a Key-Value Pair
- Get All Pairs
- Get Pairs by Reference
- Get Pairs by Key Pattern
- Foreign Constraints
- Contributing
- License
Introduction
The Pairs class allows you to create a meta table that consists of key-value pairs. Each row in the table represents a unique combination of key and reference ID, allowing you to store and retrieve data in a flexible and efficient manner. The class also supports linking the meta table to a parent table using foreign keys for data integrity and consistency.
Features
- Create a meta table with key-value pairs
- Link the meta table to a parent table using foreign keys
- Add or update reference data based on key and reference ID
- Retrieve reference data based on key and reference ID
- Remove reference data based on key and reference ID
- Retrieve all data associated with a specific reference ID or matching a given pattern
- Utilizes the sQuery library for efficient SQL query generation.
Requirements
- PHP 8.1 or higher
- MySQLi extension
- sQuery library (required for efficient query generation)
Installation
Usage
Initialization
Set a Key-Value Pair
This sets the key "car" with the value "toyota" for the reference (owner) 2.
Retrieve a Value
This retrieves the value for the key "car" and reference 2.
Retrieve a Timestamp
This retrieves the unix timestamp representing when the initial value for the specified key and reference was added to the database.
Remove a Key-Value Pair
This removes the key-value pair for the key "car" and reference 2.
Get All Pairs
This retrieves all available data grouped by reference.
Get Pairs by Reference
This retrieves all data for reference 2.
Get Pairs by Key Pattern
This retrieves all data for reference 2 whose key matches words starting from "user-"
Foreign Constraints
This sets up a foreign constraint
where "parentTableName
" becomes the parent table, and the pairs table becomes the child.
Contributing
Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request on the GitHub repository.
License
This project is licensed under the MIT License. See the LICENSE file for more information.