Skip to content

Commit

Permalink
v0.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
roberto-butti committed Nov 5, 2020
1 parent c74305c commit a7b771f
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 28 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 0.2.2 - 2020-11-05
### Add
- Add configuration parameters (config/lara-lens.php) for managing webview: LARALENS_PREFIX, LARALENS_MIDDLEWARE, LARALENS_WEB_ENABLED, thanks to @yogendra-revanna, @JexPY, @Zuruckt;
- Initial support for PHP8-rc;



## 0.2.1 - 2020-09-22
### Add
- Show available PHP extension via --show=php-ext option (thanks to https://github.com/yogendra-revanna);
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"require": {
"php": "^7.2|^8.0",
"guzzlehttp/guzzle": "^6.0|^7.0",
"illuminate/support": "^6.0|^7.0|^8.0"
"illuminate/support": "^6.0|^7.0|^8.0",
"ext-json": "*"
},
"require-dev": {
"orchestra/testbench": "4.*|5.*|6.*",
Expand Down
54 changes: 27 additions & 27 deletions src/Lens/Traits/DatabaseLens.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,29 +55,33 @@ public function dbConnection()
return $dbconnection;
}

public function getDatabaseConnectionInfos(ConnectionInterface $dbconnection, ResultLens $results, $checkTable, $columnSorting)
{
$connectionName = $dbconnection->getName();
public function getDatabaseConnectionInfos(
ConnectionInterface $dbConnection,
ResultLens $results,
$checkTable,
$columnSorting
) {
$connectionName = $dbConnection->getName();
$results->add(
"Connection name",
$connectionName
);
$grammar = $dbconnection->getQueryGrammar();
$grammar = $dbConnection->getQueryGrammar();
$results->add(
"Query Grammar",
Str::afterLast(get_class($grammar), '\\')
);
$driverName = $dbconnection->getDriverName();
$driverName = $dbConnection->getDriverName();
$results->add(
"Driver name",
$driverName
);
$databaseName = $dbconnection->getDatabaseName();
$databaseName = $dbConnection->getDatabaseName();
$results->add(
"Database name",
$databaseName
);
$tablePrefix = $dbconnection->getTablePrefix();
$tablePrefix = $dbConnection->getTablePrefix();
$results->add(
"Table prefix",
$tablePrefix
Expand All @@ -86,7 +90,7 @@ public function getDatabaseConnectionInfos(ConnectionInterface $dbconnection, Re
$pdo = null;
$pdoIsOk = false;
try {
$pdo = $dbconnection->getPDO();
$pdo = $dbConnection->getPDO();
$pdoIsOk = true;
} catch (\PDOException $e) {
$this->checksBag->addWarningAndHint(
Expand All @@ -104,17 +108,10 @@ public function getDatabaseConnectionInfos(ConnectionInterface $dbconnection, Re
""
);
} else {
/*
$this->checksBag->addWarningAndHint(
"Connection and PDO driver",
"Your DB doesn't support PDO driver (". $driverName. ").",
""
);
*/
}
} else {
try {
$serverVersion = $dbconnection->getPDO()->getAttribute(\PDO::ATTR_SERVER_VERSION);
$serverVersion = $dbConnection->getPDO()->getAttribute(\PDO::ATTR_SERVER_VERSION);
$results->add(
"Server version",
$serverVersion
Expand All @@ -131,7 +128,7 @@ public function getDatabaseConnectionInfos(ConnectionInterface $dbconnection, Re
}


$connectionType = $dbconnection->getPDO()->getAttribute(\PDO::ATTR_DRIVER_NAME);
$connectionType = $dbConnection->getPDO()->getAttribute(\PDO::ATTR_DRIVER_NAME);
$results->add(
"Database connection type",
$connectionType
Expand All @@ -154,18 +151,21 @@ public function getDatabaseConnectionInfos(ConnectionInterface $dbconnection, Re
$stringTables
);

$checkountMessage = "";
$checkCountMessage = "";
$checkCount = 0;
try {
$checkcount = DB::table($checkTable)
$checkCount = DB::table($checkTable)
->select(DB::raw('*'))
->count();
} catch (\Exception $e) {
$checkcount = 0;
$checkountMessage = " - error with " . $checkTable . " table";
$checkCount = 0;
$checkCountMessage = " - error with " . $checkTable . " table";
$results->addErrorAndHint(
"Table Error",
"Failed query, table <" . $checkTable . "> ",
"Make sure that table <" . $checkTable . "> exists, available tables : " . (($stringTables == "") ? "Not tables found" : $stringTables)
"Make sure that table <" . $checkTable .
"> exists, available tables : " .
(($stringTables == "") ? "Not tables found" : $stringTables)
);
}

Expand All @@ -175,9 +175,9 @@ public function getDatabaseConnectionInfos(ConnectionInterface $dbconnection, Re
);
$results->add(
"Number of rows",
$checkcount . $checkountMessage
$checkCount . $checkCountMessage
);
if ($checkcount > 0) {
if ($checkCount > 0) {
try {
$latest = DB::table($checkTable)->latest($columnSorting)->first();
$results->add(
Expand All @@ -199,15 +199,15 @@ public function getDatabase($checkTable = "users", $columnSorting = "created_at"
{
$results = new ResultLens();

$dbconnection = $this->dbConnection();
$dbConnection = $this->dbConnection();


$results->add(
"Database default",
config("database.default")
);
if ($dbconnection) {
$this->getDatabaseConnectionInfos($dbconnection, $results, $checkTable, $columnSorting);
if ($dbConnection) {
$this->getDatabaseConnectionInfos($dbConnection, $results, $checkTable, $columnSorting);
}


Expand Down

0 comments on commit a7b771f

Please sign in to comment.