-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extending the exception list, adding QueryException.
- Loading branch information
jsudmalis
committed
Dec 22, 2015
1 parent
427d0bb
commit 3b9e1bf
Showing
5 changed files
with
59 additions
and
32 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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
namespace js\tools\dbhandler\exceptions; | ||
|
||
class PreparedStatementException extends DbException | ||
class PreparedStatementException extends QueryException | ||
{ | ||
} |
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,30 @@ | ||
<?php | ||
namespace js\tools\dbhandler\exceptions; | ||
|
||
class QueryException extends DbException | ||
{ | ||
/** @var string */ | ||
private $query; | ||
|
||
/** | ||
* @param string $message : the error message | ||
* @param string $query : the SQL query that caused the exception (optional) | ||
* @param \PDO|null $connection : the connection to retrieve the error info from | ||
*/ | ||
public function __construct($message, $query, \PDO $connection = null) | ||
{ | ||
parent::__construct($message, $connection); | ||
|
||
$this->query = $query; | ||
} | ||
|
||
/** | ||
* Get the SQL query that caused this exception. | ||
* | ||
* @return string | ||
*/ | ||
public function getQuery() | ||
{ | ||
return print_r($this->query, true); | ||
} | ||
} |
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