implement copying of Stations for Seminary copy feature
This commit is contained in:
commit
40a233fa7d
4342 changed files with 1215466 additions and 0 deletions
87
drivers/DatabaseDriver.inc
Normal file
87
drivers/DatabaseDriver.inc
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* NRE
|
||||
*
|
||||
* @author coderkun <olli@coderkun.de>
|
||||
* @copyright 2013 coderkun (http://www.coderkun.de)
|
||||
* @license http://www.gnu.org/licenses/gpl.html
|
||||
* @link http://www.coderkun.de/projects/nre
|
||||
*/
|
||||
|
||||
namespace nre\drivers;
|
||||
|
||||
|
||||
/**
|
||||
* Abstract class for implementing a database driver.
|
||||
*
|
||||
* @author coderkun <olli@coderkun.de>
|
||||
*/
|
||||
abstract class DatabaseDriver extends \nre\core\Driver
|
||||
{
|
||||
/**
|
||||
* Driver class instance
|
||||
*
|
||||
* @static
|
||||
* @var DatabaseDriver
|
||||
*/
|
||||
protected static $driver = null;
|
||||
/**
|
||||
* Connection resource
|
||||
*
|
||||
* @var resource
|
||||
*/
|
||||
protected $connection = null;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Singleton-pattern.
|
||||
*
|
||||
* @param array $config Database driver configuration
|
||||
* @return DatabaseDriver Singleton-instance of database driver class
|
||||
*/
|
||||
public static function singleton($config)
|
||||
{
|
||||
// Singleton
|
||||
if(self::$driver !== null) {
|
||||
return self::$driver;
|
||||
}
|
||||
|
||||
// Construct
|
||||
$className = get_called_class();
|
||||
self::$driver = new $className($config);
|
||||
|
||||
|
||||
return self::$driver;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Construct a new database driver.
|
||||
*
|
||||
* @param array $config Connection and login settings
|
||||
*/
|
||||
protected function __construct($config)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
// Establish connection
|
||||
$this->connect($config);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Establish a connect to a MqSQL-database.
|
||||
*
|
||||
* @throws \nre\exceptions\DatamodelException
|
||||
* @param array $config Connection and login settings
|
||||
*/
|
||||
protected abstract function connect($config);
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue