Refactored project structure.
This commit is contained in:
parent
cfe93434ad
commit
c015d8c58b
308 changed files with 39 additions and 47 deletions
|
|
@ -1,69 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace PHPCensor\Plugin;
|
||||
|
||||
use PDO;
|
||||
use PHPCensor\Builder;
|
||||
use PHPCensor\Model\Build;
|
||||
use PHPCensor\Plugin;
|
||||
|
||||
/**
|
||||
* SQLite Plugin — Provides access to a SQLite database.
|
||||
*
|
||||
* @author Dmitry Khomutov <poisoncorpsee@gmail.com>
|
||||
*/
|
||||
class Sqlite extends Plugin
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $queries = [];
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $path;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function pluginName()
|
||||
{
|
||||
return 'sqlite';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function __construct(Builder $builder, Build $build, array $options = [])
|
||||
{
|
||||
parent::__construct($builder, $build, $options);
|
||||
|
||||
$buildSettings = $this->builder->getConfig('build_settings');
|
||||
|
||||
if (isset($buildSettings['sqlite'])) {
|
||||
$sql = $buildSettings['sqlite'];
|
||||
$this->path = $sql['path'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Connects to SQLite and runs a specified set of queries.
|
||||
* @return boolean
|
||||
*/
|
||||
public function execute()
|
||||
{
|
||||
try {
|
||||
$opts = [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION];
|
||||
$pdo = new PDO('sqlite:' . $this->path, $opts);
|
||||
|
||||
foreach ($this->queries as $query) {
|
||||
$pdo->query($this->builder->interpolate($query));
|
||||
}
|
||||
} catch (\Exception $ex) {
|
||||
$this->builder->logFailure($ex->getMessage());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue