From b8779f4a6a581cb378368eac398a262047397472 Mon Sep 17 00:00:00 2001 From: wei <> Date: Sat, 6 Jan 2007 03:36:40 +0000 Subject: Fixed #485. --- framework/Data/TDbCommand.php | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'framework/Data') diff --git a/framework/Data/TDbCommand.php b/framework/Data/TDbCommand.php index fc18a4bc..054aa653 100644 --- a/framework/Data/TDbCommand.php +++ b/framework/Data/TDbCommand.php @@ -115,7 +115,7 @@ class TDbCommand extends TComponent } catch(Exception $e) { - throw new TDbException('dbcommand_prepare_failed',$e->getMessage()); + throw new TDbException('dbcommand_prepare_failed',$e->getMessage(),$this->getText()); } } } @@ -190,10 +190,19 @@ class TDbCommand extends TComponent } catch(Exception $e) { - throw new TDbException('dbcommand_execute_failed',$e->getMessage()); + throw new TDbException('dbcommand_execute_failed',$e->getMessage(),$this->getDebugStatementText()); } } + /** + * @return String prepared SQL text for debugging purposes. + */ + protected function getDebugStatementText() + { + if(Prado::getApplication()->getMode() === TApplicationMode::Debug) + return $this->_statement instanceof PDOStatement ? $this->getConnection()->getPdoInstance().$this->_statement->queryString : $this->getText(); + } + /** * Executes the SQL statement and returns query result. * This method is for executing an SQL query that returns result set. @@ -202,7 +211,6 @@ class TDbCommand extends TComponent */ public function query() { -// Prado::debug(); try { if($this->_statement instanceof PDOStatement) @@ -213,7 +221,7 @@ class TDbCommand extends TComponent } catch(Exception $e) { - throw new TDbException('dbcommand_query_failed',$e->getMessage()); + throw new TDbException('dbcommand_query_failed',$e->getMessage(),$this->getDebugStatementText()); } } @@ -239,7 +247,7 @@ class TDbCommand extends TComponent } catch(Exception $e) { - throw new TDbException('dbcommand_query_failed',$e->getMessage()); + throw new TDbException('dbcommand_query_failed',$e->getMessage(),$this->getDebugStatementText()); } } @@ -267,7 +275,7 @@ class TDbCommand extends TComponent } catch(Exception $e) { - throw new TDbException('dbcommand_query_failed',$e->getMessage()); + throw new TDbException('dbcommand_query_failed',$e->getMessage(),$this->getDebugStatementText()); } } } -- cgit v1.2.3