summaryrefslogtreecommitdiff
path: root/framework/Data
diff options
context:
space:
mode:
authorwei <>2007-01-06 03:36:40 +0000
committerwei <>2007-01-06 03:36:40 +0000
commitb8779f4a6a581cb378368eac398a262047397472 (patch)
treeec9949b1f2ebe9a1f9972e595b4d6a4b925103b9 /framework/Data
parentbde6488e19b9852011a657fda8aa39680d9c4a62 (diff)
Fixed #485.
Diffstat (limited to 'framework/Data')
-rw-r--r--framework/Data/TDbCommand.php20
1 files changed, 14 insertions, 6 deletions
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,11 +190,20 @@ 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.
* @return TDbDataReader the reader object for fetching the query result
@@ -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());
}
}
}