PHP code example of radynsade / database-clock

1. Go to this page and download the library: Download radynsade/database-clock 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/ */

    

radynsade / database-clock example snippets


use DatabaseClock\PostgreSql\PdoClock;
use PDO;

$connection = new PDO(
	'pgsql:host=localhost;dbname=app',
	'postgres',
	'secret',
);

$clock = new PdoClock($connection);
$currentTime = $clock->now();

use DatabaseClock\MySql\MysqliClock;
use mysqli;

$connection = new mysqli(
	'localhost',
	'root',
	'secret',
	'app',
);

$clock = new MysqliClock($connection);
$currentTime = $clock->now();

use DatabaseClock\PostgreSql\PgsqlClock;
use RuntimeException;

$connection = pg_connect('host=localhost dbname=app user=postgres password=secret');

if ($connection === false) {
	throw new RuntimeException('Failed to connect to PostgreSQL.');
}

$clock = new PgsqlClock($connection);
$currentTime = $clock->now();