-
Notifications
You must be signed in to change notification settings - Fork 631
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1511 from Ultimater/fix-1479-pdo-adapter-error-4.1.x
Fix #1479 more verbose pdo driver missing errors for 4.1.x
- Loading branch information
Showing
3 changed files
with
66 additions
and
2 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
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,46 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* This file is part of the Phalcon Developer Tools. | ||
* | ||
* (c) Phalcon Team <team@phalcon.io> | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Phalcon\DevTools\Exception; | ||
|
||
use PDOException; | ||
use Phalcon\Devtools\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); | ||
} | ||
} | ||
} |