Files
pathfinder/app/Db/Sql/Mysql/Session.php
Mark Friedrich 647bd7db58 - BC Break: _PHP_ namespaces changed (PSR-4 standard). The _root_ namespace for all _PF_ related scripts is Exodus4D\Pathfinder
- BC Break: Project folder structure changed. Removed `app/main` dir.
- BC Break: Core _PHP_ framework + dependencies moved into `composer.json` and are no longer part of this repo
2019-12-15 22:27:17 +01:00

46 lines
1.5 KiB
PHP

<?php
/**
* Created by PhpStorm.
* User: Exodus 4D
* Date: 02.12.2018
* Time: 15:40
*/
namespace Exodus4D\Pathfinder\Db\Sql\Mysql;
class Session extends \DB\SQL\Session {
/**
* Session constructor.
* @param \DB\SQL $db
* @param string $table
* @param bool $force
* @param callback $onsuspect
* @param string $key
*/
function __construct(\DB\SQL $db, string $table = 'sessions', bool $force = true, $onsuspect = null, $key = null){
if($force){
// create sessions table
// -> We use this "custom" SQl rather than the default in parent::__construct()
// because of the defaults 'data' column type TEXT
$dbName = $db->name();
$sql = "CREATE TABLE IF NOT EXISTS ";
$sql .= $dbName ? $db->quotekey($dbName,FALSE) . "." : "";
$sql .= $db->quotekey($table,FALSE) . " (";
$sql .= $db->quotekey('session_id') . " VARCHAR(255),";
$sql .= $db->quotekey('data') . " MEDIUMTEXT,";
$sql .= $db->quotekey('ip') . " VARCHAR(45),";
$sql .= $db->quotekey('agent') . " VARCHAR(300),";
$sql .= $db->quotekey('stamp') . " INT(11),";
$sql .= "PRIMARY KEY (" . $db->quotekey('session_id') . ")";
$sql .= ");";
$db->exec($sql);
}
// $force = false for parent constructor -> skip default create SQL
parent::__construct($db, $table, false, $onsuspect, $key);
}
}