1. Go to this page and download the library: Download ody/database 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/ */
use Ody\DB\Doctrine\Facades\ORM;
use App\Entities\User;
// Get entity manager
$entityManager = ORM::entityManager();
// Working with entities
$user = $entityManager->find(User::class, 1);
$entityManager->persist($user);
$entityManager->flush();
use Ody\DB\Doctrine\Facades\DBAL;
// Execute queries
$users = $this->connection->fetchAllAssociative('SELECT * FROM users WHERE active = ?', [1]);
// Using query builder
$queryBuilder = $this->connection->createQueryBuilder();
$result = $queryBuilder
->select('u.*')
->from('users', 'u')
->where('u.active = :active')
->setParameter('active', 1)
->executeQuery()
->fetchAllAssociative();
use Ody\DB\ConnectionManager;
// Initialize the pool
ConnectionManager::initPool($config);
// Get a connection from the pool
$connection = ConnectionManager::getConnection();
// Use the PDO connection
$stmt = $connection->prepare('SELECT * FROM users WHERE id = ?');
$stmt->execute([1]);
$user = $stmt->fetch(PDO::FETCH_ASSOC);
// No need to return the connection - it's automatically returned when the coroutine ends
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.