https://github.com/sensorario/orma
An orm made just for study scope
https://github.com/sensorario/orma
orm php-project php8
Last synced: 18 days ago
JSON representation
An orm made just for study scope
- Host: GitHub
- URL: https://github.com/sensorario/orma
- Owner: sensorario
- Created: 2023-05-30T20:06:08.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-06-03T09:44:56.000Z (almost 3 years ago)
- Last Synced: 2025-07-17T20:55:57.610Z (9 months ago)
- Topics: orm, php-project, php8
- Language: PHP
- Homepage:
- Size: 50.8 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# ORMA
- you can create tables
- add columns
- CRUD operations
- designed for sqlite or postgresql
## install
```
composer require sensorario/orma
```
Copy `vendor/sensorario/orma/public/index.php` on your project root.
SQLite does not require any installation. Postgres can be used with docker: `vendor/sensorario/orma/docker-compose.yaml`.
Happy coding
## pdo
Postgres data refers to docker machine inside the project.
```php
$config = [
'postgresql' => [
'dns' => 'pgsql:host=database;dbname=your_database_name',
'username' => 'your_username',
'password' => 'your_password',
],
'sqlite' => [
'dns' => 'sqlite:./erdatabase',
],
'db' => 'postgresql',
'db' => 'sqlite',
];
$pdo = new PDO(
$config[$config['db']]['dns'],
$config[$config['db']]['username'],
$config[$config['db']]['password'],
);
```
## init
```php
$orma = new Orma($pdo, match($driver) {
'sqlite' => new SQLiteDriver,
'postgresql' => new PostgreSQLDriver,
});
```
## create a table
```php
$orma($table)->createTable();
```
## add a column
```php
$orma->addColumn($column);
```
## insert
```php
$orma->insert([ 'id' => 42, ]);
```
## delete
```php
$orma->delete([ 'id' => 42, ]);
```
## update
```php
$orma->update([ 'foo' => 'bar', ], [ 'id' => 42, ]);
```
PS. This repo is made just for fun.