Enable SQL logging only in debug mode
This commit is contained in:
parent
d27080616c
commit
a7cbea3e02
@ -9,10 +9,11 @@ use PicoDb;
|
|||||||
function get_connection()
|
function get_connection()
|
||||||
{
|
{
|
||||||
$db = new PicoDb\Database(get_connection_parameters());
|
$db = new PicoDb\Database(get_connection_parameters());
|
||||||
$db->getStatementHandler()->withLogging();
|
|
||||||
|
|
||||||
if (DEBUG_MODE) {
|
if (DEBUG_MODE) {
|
||||||
$db->getStatementHandler()->withStopWatch();
|
$db->getStatementHandler()
|
||||||
|
->withLogging()
|
||||||
|
->withStopWatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($db->schema('\Miniflux\Schema')->check(Schema\VERSION)) {
|
if ($db->schema('\Miniflux\Schema')->check(Schema\VERSION)) {
|
||||||
@ -20,7 +21,7 @@ function get_connection()
|
|||||||
} else {
|
} else {
|
||||||
$errors = $db->getLogMessages();
|
$errors = $db->getLogMessages();
|
||||||
$nb_errors = count($errors);
|
$nb_errors = count($errors);
|
||||||
$last_error = isset($errors[$nb_errors - 1]) ? $errors[$nb_errors - 1] : 'Unknown SQL error';
|
$last_error = isset($errors[$nb_errors - 1]) ? $errors[$nb_errors - 1] : 'Enable debug mode to have more information';
|
||||||
throw new RuntimeException('Unable to migrate the database schema: '.$last_error);
|
throw new RuntimeException('Unable to migrate the database schema: '.$last_error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user