forked from phalcon/phalcon-devtools
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix phalcon#1479 more verbose pdo driver missing errors
- Loading branch information
Showing
3 changed files
with
76 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
scripts/Phalcon/Exception/Db/PDODriverNotFoundException.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
/* | ||
+------------------------------------------------------------------------+ | ||
| Phalcon Developer Tools | | ||
+------------------------------------------------------------------------+ | ||
| Copyright (c) 2011-present Phalcon Team (https://www.phalconphp.com) | | ||
+------------------------------------------------------------------------+ | ||
| This source file is subject to the New BSD License that is bundled | | ||
| with this package in the file LICENSE.txt. | | ||
| | | ||
| If you did not receive a copy of the license and are unable to | | ||
| obtain it through the world-wide-web, please send an email | | ||
| to [email protected] so we can send you a copy immediately. | | ||
+------------------------------------------------------------------------+ | ||
| Authors: Kevin Yarmak <[email protected]> | | ||
+------------------------------------------------------------------------+ | ||
*/ | ||
|
||
namespace Phalcon\Exception\Db; | ||
|
||
use PDOException; | ||
use Phalcon\Script\Color; | ||
use PDO; | ||
|
||
class PDODriverNotFoundException extends PDOException | ||
{ | ||
protected $adapter = ''; | ||
|
||
public function __construct($message, $adapter = '') | ||
{ | ||
parent::__construct($message); | ||
$this->adapter = $adapter; | ||
} | ||
|
||
public function getAdapter() | ||
{ | ||
return $this->adapter; | ||
} | ||
|
||
public function writeNicelyFormattedErrorOutput() | ||
{ | ||
fwrite(STDERR, Color::error($this->getMessage()) . PHP_EOL); | ||
|
||
if (!extension_loaded('PDO')) { | ||
fwrite(STDERR, Color::error('PDO extension is not loaded') . PHP_EOL); | ||
} else { | ||
$loadedDrivers = PDO::getAvailableDrivers(); | ||
fwrite(STDERR, 'PDO Drivers loaded:' . PHP_EOL); | ||
fwrite(STDERR, print_r($loadedDrivers, true). PHP_EOL); | ||
} | ||
} | ||
} |