diff options
Diffstat (limited to 'main/app/system/Bakery/DatabaseTest.php')
-rw-r--r-- | main/app/system/Bakery/DatabaseTest.php | 102 |
1 files changed, 51 insertions, 51 deletions
diff --git a/main/app/system/Bakery/DatabaseTest.php b/main/app/system/Bakery/DatabaseTest.php index 91d2c2b..046c4c5 100644 --- a/main/app/system/Bakery/DatabaseTest.php +++ b/main/app/system/Bakery/DatabaseTest.php @@ -1,52 +1,52 @@ -<?php -/** - * UserFrosting (http://www.userfrosting.com) - * - * @link https://github.com/userfrosting/UserFrosting - * @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License) - */ - -namespace UserFrosting\System\Bakery; - -use Illuminate\Database\Capsule\Manager as Capsule; - -/** - * Database Test Trait. Include method to test the db connexion - * - * @author Alex Weissman (https://alexanderweissman.com) - */ -trait DatabaseTest -{ - - /** - * Function to test the db connexion. - * - * @access protected - * @return bool True if success - */ - protected function testDB() { - // Boot db - $this->ci->db; - - // Get config - $config = $this->ci->config; - - // Check params are valids - $dbParams = $config['db.default']; - if (!$dbParams) { - throw new \Exception("'default' database connection not found. Please double-check your configuration."); - } - - // Test database connection directly using PDO - try { - Capsule::connection()->getPdo(); - } catch (\PDOException $e) { - $message = "Could not connect to the database '{$dbParams['username']}@{$dbParams['host']}/{$dbParams['database']}':" . PHP_EOL; - $message .= "Exception: " . $e->getMessage() . PHP_EOL . PHP_EOL; - $message .= "Please check your database configuration and/or google the exception shown above and run command again."; - throw new \Exception($message); - } - - return TRUE; - } +<?php
+/**
+ * UserFrosting (http://www.userfrosting.com)
+ *
+ * @link https://github.com/userfrosting/UserFrosting
+ * @license https://github.com/userfrosting/UserFrosting/blob/master/licenses/UserFrosting.md (MIT License)
+ */
+
+namespace UserFrosting\System\Bakery;
+
+use Illuminate\Database\Capsule\Manager as Capsule;
+
+/**
+ * Database Test Trait. Include method to test the db connexion
+ *
+ * @author Alex Weissman (https://alexanderweissman.com)
+ */
+trait DatabaseTest
+{
+
+ /**
+ * Function to test the db connexion.
+ *
+ * @access protected
+ * @return bool True if success
+ */
+ protected function testDB() {
+ // Boot db
+ $this->ci->db;
+
+ // Get config
+ $config = $this->ci->config;
+
+ // Check params are valids
+ $dbParams = $config['db.default'];
+ if (!$dbParams) {
+ throw new \Exception("'default' database connection not found. Please double-check your configuration.");
+ }
+
+ // Test database connection directly using PDO
+ try {
+ Capsule::connection()->getPdo();
+ } catch (\PDOException $e) {
+ $message = "Could not connect to the database '{$dbParams['username']}@{$dbParams['host']}/{$dbParams['database']}':" . PHP_EOL;
+ $message .= "Exception: " . $e->getMessage() . PHP_EOL . PHP_EOL;
+ $message .= "Please check your database configuration and/or google the exception shown above and run command again.";
+ throw new \Exception($message);
+ }
+
+ return TRUE;
+ }
}
\ No newline at end of file |