/**
* Provide functionality for use PDO with one connection
*/
class DB extends PDO {
/**
* @var PDO Link to connection
*/
protected static $_instance;
/**
* Creates a PDO instance representing a connection to a database
* @link http://php.net/manual/en/pdo.construct.php
* @param $dsn
* @param $username [optional]
* @param $password [optional]
* @param $options [optional]
*/
public function __construct($dsn, $username = NULL, $password = NULL, $options = NULL) {
parent::__construct($dsn, $username, $password, $options);
}
/**
* @static Return PDO connection instance
* @return PDO Link to connection
* @throws Exception
*/
public static function getInstance() {
if (is_null(self::$_instance)) {
$filepath = dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'db' . DIRECTORY_SEPARATOR . 'database.sqlite';
self::$_instance = new self('sqlite:' . $filepath);
self::$_instance->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
if (is_null(self::$_instance)) {
throw new Exception('Could not connect to database');
}
}
return self::$_instance;
}
}
width: 90.05%
. Скролл не появился.Если у вас почему-то появился, уберите его с помощью
overflow: hidden