I have a Drupal site on a web server. On one page of the site, I want to print out information from a sqlite database. But if I enter the url to the page, I get redirected to /core/install.php
I integrated the database into the /sites/defualt/settings.php with the following code:
$databases['external']['default'] = [
'driver' => 'sqlite',
'database' => '/gesamtausgabe_2019.sqlite',
];
I created a module with the /modules/database_mindmap/src/Controller/database_mindmapController.php:
<?php
namespace Drupal\database_mindmap\Controller;
class database_mindmapController{
public function database_mindmap(){
return include('visual.php');
}
}
?>
In the included visual.php I call and query the Database with the folowing code:
<?php
//open the database
\Drupal\Core\Database\Database::setActiveConnection('external');
$database = \Drupal\Core\Database\Database::getConnection();
$staticID = '008dd40a-9687-4c84-bbfd-95cf0639e09a';
$sql = 'SELECT * FROM KnowledgeItem';
$query = $database->db_query($sql);
$result = array($query);
while($row = $result) {
if (strpos($row['StaticIDs'], $staticID) !== false){
$pagerange_all = explode(" ",$row['PageRange']);
$text = "<h4>".$row['CoreStatement']."</h4>".$row['Text']."<br><br><i>Seitenzahl: ".$pagerange_all[9]." ".$pagerange_all[11]."</i>";
echo $text;
}
}
// close the database connection
Drupal\Core\Database\Database::setActiveConnection();
?>
So for some strange reason, everytime I call the module with /database/mindmap I get redirected to /core/install.php
Thanks for any help!