DDDBL 2.0
 All Classes Namespaces Files Functions Variables
Public Member Functions | Private Member Functions | List of all members
DDDBL\QueryException Class Reference
Inheritance diagram for DDDBL\QueryException:

Public Member Functions

 __construct (\PDOStatement $objPDO, array $arrQueryDefinition)
 

Private Member Functions

 createErrorMessage (\PDOStatement $objPDO, array $arrQueryDefinition)
 
 flattenQueryDefiniton (array $arrQueryDefinition)
 
 flattenQueryErrorInfo (\PDOStatement $objPDO)
 

Detailed Description

create an exception with relevant information, if a query fails

Definition at line 11 of file QueryException.class.php.

Constructor & Destructor Documentation

DDDBL\QueryException::__construct ( \PDOStatement  $objPDO,
array  $arrQueryDefinition 
)
Parameters
$objPDO- the PDO object which caused the error when executed
$arrQueryDefinition- the complete query definition

create an error message which contains all relevant informations and print them as exception

Definition at line 22 of file QueryException.class.php.

22  {
23 
24  $strMessage = self::createErrorMessage($objPDO, $arrQueryDefinition);
25 
26  parent::__construct($strMessage);
27 
28  }

Member Function Documentation

DDDBL\QueryException::createErrorMessage ( \PDOStatement  $objPDO,
array  $arrQueryDefinition 
)
private
Parameters
$objPDO- the PDO object related with the error
$arrQueryDefinition- the complete query definition
Returns
(string) the complete exception message

build and return the exception message out of the given error info and query definition

Definition at line 41 of file QueryException.class.php.

41  {
42 
43  $strMessage = self::flattenQueryErrorInfo($objPDO);
44  $strMessage .= self::flattenQueryDefiniton($arrQueryDefinition);
45 
46  return $strMessage;
47 
48  }
DDDBL\QueryException::flattenQueryDefiniton ( array  $arrQueryDefinition)
private
Parameters
$arrQueryDefinition- the complete query definition
Returns
(string) a text version of the query definition

create an text, which contains all scalar information of the query definition. if there are non-scalar information added, the will be excluded from output

Definition at line 84 of file QueryException.class.php.

84  {
85 
86  $strMessage = "\nQuery-Definiton:\n";
87 
88  foreach($arrQueryDefinition AS $strKeyword => $strContent)
89  if(is_scalar($strContent))
90  $strMessage .= "$strKeyword: $strContent\n";
91 
92  return $strMessage . "\n";
93 
94  }
DDDBL\QueryException::flattenQueryErrorInfo ( \PDOStatement  $objPDO)
private
Parameters
$objPDO- PDO object to get error information from
Returns
(string) a flatten error info from the query object

build and return a flatten error-info from the driver specific error message

Definition at line 60 of file QueryException.class.php.

60  {
61 
62  $arrErrorInfo = $objPDO->errorInfo();
63 
64  $strMessage = '';
65 
66  if(!empty($arrErrorInfo) && !empty($arrErrorInfo[0]) && '00000' !== $arrErrorInfo[0])
67  $strMessage = "\nError-Code: {$arrErrorInfo[0]}\nError-Message: {$arrErrorInfo[2]}\n";
68 
69  return $strMessage;
70 
71  }

The documentation for this class was generated from the following file: