1. Go to this page and download the library: Download stk2k/power-pdo 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/ */
stk2k / power-pdo example snippets
class UserEntity
{
public $ID;
public $deleted;
public $user_name;
public $nickname;
public $email;
}
use Stk2k\PowerPDO\PowerPDO;
$dsn = 'mysql:dbname=mydatabase;host=localhost';
$user = 'myuser';
$password = 'mypass';
$ppdo = new PowerPDO(new PDO($dsn, $user, $password));
or
$ppdo = PowerPDO::make($dsn, $user, $password);
use Stk2k\PowerPDO\PowerPDO;
$dsn = 'sqlite:/path/to/dbfile_of_sqlite';
$ppdo = new PowerPDO(new PDO($dsn));
or
$ppdo = PowerPDO::make($dsn);
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
// monolog
$log = new Logger('name');
$log->pushHandler(new StreamHandler('path/to/your.log', Logger::WARNING));
$ppdo = new PowerPDO(new PDO($dsn), $log);
or
$ppdo = PowerPDO::make($dsn)->logger($log);