PHP Classes

File: demos/db.default.php

Recommend this page to a friend!
  Classes of Francesco Danti   ATK4 Session   demos/db.default.php   Download  
File: demos/db.default.php
Role: Example script
Content type: text/plain
Description: Example script
Class: ATK4 Session
Store and retrieve PHP session data in a database
Author: By
Last change:
Date: 6 hours ago
Size: 614 bytes
 

Contents

Class file image Download
<?php

declare(strict_types=1);

namespace
Atk4\ATK4DBSession\Demos;

use
Atk4\Data\Persistence;

// to use MySQL database:
// 1. copy this file to "db.php"
// 2. uncomment the line below (and update the configuration if needed)
// 3. remove the Sqlite code from the new file
// $db = new Persistence\Sql('mysql:dbname=atk4_test__ui;host=mysql', 'atk4_test', 'atk4_pass');

$sqliteFile = __DIR__ . '/_demo-data/db.sqlite';
if (!
file_exists($sqliteFile)) {
    throw new \
Exception('Sqlite database does not exist, create it first.');
}
$db = new Persistence\Sql('sqlite:' . $sqliteFile);
unset(
$sqliteFile);