Download the PHP package birkanoruc/simple-orm without Composer
On this page you can find all versions of the php package birkanoruc/simple-orm. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download birkanoruc/simple-orm
More information about birkanoruc/simple-orm
Files in birkanoruc/simple-orm
Package simple-orm
Short Description A lightweight ORM and database management library.
License MIT
Informations about the package simple-orm
Simple ORM
Simple ORM is a lightweight Object-Relational Mapping library for PHP, designed to simplify database interactions and provide a clean and intuitive API for working with database records.
Table of Contents
- Installation
- Configuration
- Usage
- Creating a Database Connection
- Creating a Model
- Querying Data
- Inserting Data
- Updating Data
- Deleting Data
- Relationships
- Aggregates
- License
Installation
To get started with Simple ORM, you can clone the repository or require it via Composer:
Configuration
You need to configure your database connection settings. The following parameters are required:
- host: Database server address (e.g.,
localhost
) - port: Your DB port (e.g.,
3306
) - dbname: Database name
- charset: Character set (default is
utf8mb4
)
Usage
Creating a Database Connection
To create a new database connection, instantiate the Database class with your configuration:
Creating a Model
Create a model by extending the Model class. Define the table name in the model:
Querying Data
To retrieve all records:
To retrieve the first record:
To find a specific record by ID:
To apply a WHERE clause:
Inserting Data
To insert a new record:
Updating Data
To update an existing record:
Deleting Data
To delete a record:
To delete multiple records:
Relationships
Define relationships within your model:
Has One
Has Many
Belongs To
Belongs To Many
Aggregates
To perform aggregate queries:
License
This project is licensed under the MIT License - see the LICENSE file for details.
Explanations:
- Project Introduction: Clearly states the purpose of the library and what it does.
- Installation: Provides information on how to install and configure the library.
- Usage: Contains examples of how to use the library.
- Relationships: Offers information on how to define model relationships.
- Aggregates: Explains how to perform aggregate queries.