Use read only database connection

This commit is contained in:
Dennis Eichhorn 2017-09-22 19:18:18 +02:00
parent 684d6369a8
commit 1092e945ea

View File

@ -141,7 +141,7 @@ class ModuleManager
public function getUriLoad(Request $request) : array public function getUriLoad(Request $request) : array
{ {
if (!isset($this->uriLoad)) { if (!isset($this->uriLoad)) {
switch ($this->app->dbPool->get('core')->getType()) { switch ($this->app->dbPool->get('select')->getType()) {
case DatabaseType::MYSQL: case DatabaseType::MYSQL:
$uriHash = $request->getHash(); $uriHash = $request->getHash();
$uriPdo = ''; $uriPdo = '';
@ -157,11 +157,11 @@ class ModuleManager
$uriPdo = rtrim($uriPdo, ','); $uriPdo = rtrim($uriPdo, ',');
/* TODO: make join in order to see if they are active */ /* TODO: make join in order to see if they are active */
$sth = $this->app->dbPool->get('core')->con->prepare( $sth = $this->app->dbPool->get('select')->con->prepare(
'SELECT 'SELECT
`' . $this->app->dbPool->get('core')->prefix . 'module_load`.`module_load_type`, `' . $this->app->dbPool->get('core')->prefix . 'module_load`.* `' . $this->app->dbPool->get('select')->prefix . 'module_load`.`module_load_type`, `' . $this->app->dbPool->get('select')->prefix . 'module_load`.*
FROM FROM
`' . $this->app->dbPool->get('core')->prefix . 'module_load` `' . $this->app->dbPool->get('select')->prefix . 'module_load`
WHERE WHERE
`module_load_pid` IN(' . $uriPdo . ')' `module_load_pid` IN(' . $uriPdo . ')'
); );
@ -191,9 +191,9 @@ class ModuleManager
public function getActiveModules() : array public function getActiveModules() : array
{ {
if ($this->active === null) { if ($this->active === null) {
switch ($this->app->dbPool->get('core')->getType()) { switch ($this->app->dbPool->get('select')->getType()) {
case DatabaseType::MYSQL: case DatabaseType::MYSQL:
$sth = $this->app->dbPool->get('core')->con->prepare('SELECT `module_path` FROM `' . $this->app->dbPool->get('core')->prefix . 'module` WHERE `module_active` = 1'); $sth = $this->app->dbPool->get('select')->con->prepare('SELECT `module_path` FROM `' . $this->app->dbPool->get('select')->prefix . 'module` WHERE `module_active` = 1');
$sth->execute(); $sth->execute();
$this->active = $sth->fetchAll(\PDO::FETCH_COLUMN); $this->active = $sth->fetchAll(\PDO::FETCH_COLUMN);
break; break;
@ -289,9 +289,9 @@ class ModuleManager
public function getInstalledModules() : array public function getInstalledModules() : array
{ {
if ($this->installed === null) { if ($this->installed === null) {
switch ($this->app->dbPool->get('core')->getType()) { switch ($this->app->dbPool->get('select')->getType()) {
case DatabaseType::MYSQL: case DatabaseType::MYSQL:
$sth = $this->app->dbPool->get('core')->con->prepare('SELECT `module_id`,`module_theme`,`module_version` FROM `' . $this->app->dbPool->get('core')->prefix . 'module`'); $sth = $this->app->dbPool->get('select')->con->prepare('SELECT `module_id`,`module_theme`,`module_version` FROM `' . $this->app->dbPool->get('select')->prefix . 'module`');
$sth->execute(); $sth->execute();
$this->installed = $sth->fetchAll(\PDO::FETCH_GROUP); $this->installed = $sth->fetchAll(\PDO::FETCH_GROUP);
break; break;