basteyy / medoo-orm
An ORM Mapper for using Medoo as an Object-ORM Tool
0.0.3
2023-11-15 16:34 UTC
Requires
- ext-mysqli: *
- basteyy/minimal-hash-wrapper: ^1.0
- basteyy/various-php-snippets: 0.0.1
- catfan/medoo: ^2.1
- symfony/console: ^6.0
This package is auto-updated.
Last update: 2024-11-15 18:41:39 UTC
README
Hi! This is (my personal) Medoo ORM Mapping-Class for mapping the database based on Medoo into classes.
Setup
Use composer to add the Mapper to your code:
composer require basteyy/medoo-orm
Config
There are a few ways to config this.
Create the Medoo-Instance by yourself
You can create the medoo instance somewhere in your code and than load the tables by passing it:
$config = []; // Config $medoo = new \Medoo\Medoo($config); $usersTable = new UsersTable($medoo);
Use Dependency Injection
Create a definition somewhere in your code and simple call the tables:
$DI->addDefinitions([ \Medoo\Medoo::class => function () { $config = []; // Config return new \Medoo\Medoo($config); }, // OR (!!) 'connection' => => function () { $config = []; // Config return new \Medoo\Medoo($config); }, // OR (!!) 'DB' => => function () { $config = []; // Config return new \Medoo\Medoo($config); }, // OR (!!) 'DatabaseConnection' => => function () { $config = []; // Config return new \Medoo\Medoo($config); } ]);
Passing the config as a array
You can simple pass the config as an array to the tables and let the script doing the instance-job:
$config = []; // The Config $usersTable = new FancyTableClassTable($config);
License
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.