1. Go to this page and download the library: Download hegentopf/easy-orm library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
hegentopf / easy-orm example snippets
use Hegentopf\EasyOrm\connection\ConnectionManager;
use Hegentopf\EasyOrm\connection\MySQLConnection;
// Set up the database connection, adjust parameters as needed.
// Use .env or config files in production
$default = new MySQLConnection( 'dbName', 'user', 'passwd', 'localhost', 3306 );
ConnectionManager::setConnection( $default );
// For multiple connections, you can set and get connections by name
$replication = new MySQLConnection( 'dbName', 'user', 'passwd', 'localhost', 3307 );
ConnectionManager::setConnection( $replication, 'replication' );
use App\dbModels\test\ProductModel;
// Create a new model
$productModel = new ProductModel();
$productModel->setName( 'Screwdriver' )->setPrice( 15.40 )->save();
// Fetch all models
$productModel = ProductModel::getQueryBuilder()->get();
// Fetch a single model by primary key
$productModel = ProductModel::fetchById( 1 );
// Update a model
$productModel->setName( 'Nail' )->setPrice( 0.22 )->save();
// Delete a model
$productModel->delete();