Download the PHP package joaojkuligowski/mypersist without Composer
On this page you can find all versions of the php package joaojkuligowski/mypersist. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download joaojkuligowski/mypersist
More information about joaojkuligowski/mypersist
Files in joaojkuligowski/mypersist
Package mypersist
Short Description A very simple persistence layer for PHP Projects
License MIT
Homepage https://github.com/joaojkuligowski/mypersist
Informations about the package mypersist
MyPersist
MyPersist is a lightweight micro ORM (Object-Relational Mapping) for PHP that supports both PDO (for database interaction) and JSON files (for lightweight data storage). This library allows you to easily create, read, update, and delete data while maintaining a clean and simple codebase.
Features
- Support for SQLite databases using PDO.
- Option to use JSON files for data storage.
- Automatic table creation and column management.
- Upsert functionality to handle both inserts and updates.
- Simple API for interacting with your data.
Installation
You can install MyPersist via Composer.
Usage
Setup
First, create a new instance of the Base
class. You can choose the storage driver (PDO or JSON).
Using PDO (SQLite)
Using JSON
Basic Operations
Inserting Data
To insert data into a table, use the insert
method:
Selecting Data
To retrieve data from a table, use the select
method:
Upserting Data
To insert or update a record, use the upsert
method. This is particularly useful for maintaining unique records:
Working with joins
To join data, use the join method:
Docs
Complete Documentation
Table and Column Management
The library automatically creates tables and columns as needed. If you insert data into a table that doesn’t exist, it will be created with the appropriate columns.
Error Handling
All methods include basic error handling. If an error occurs during database operations, it will output an error message. You can further enhance error handling based on your requirements.
Running Tests
You can run the tests using PHPUnit. First, ensure you have PHPUnit installed, then execute:
Contributing
If you'd like to contribute to MyPersist, feel free to fork the repository and submit a pull request. Ensure you follow the coding standards and include tests for any new features or bug fixes.
License
This project is licensed under the MIT License. See the LICENSE file for details.