[pLog-svn] r3497 - plog/trunk/class/dao
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Wed May 31 20:51:28 GMT 2006
Author: oscar
Date: 2006-05-31 20:51:27 +0000 (Wed, 31 May 2006)
New Revision: 3497
Modified:
plog/trunk/class/dao/model.class.php
Log:
the error message, if any, is lost after a close. Now we keep the message by default as soon as
an error happens, so that we can check it anytime later.
Modified: plog/trunk/class/dao/model.class.php
===================================================================
--- plog/trunk/class/dao/model.class.php 2006-05-31 20:50:47 UTC (rev 3496)
+++ plog/trunk/class/dao/model.class.php 2006-05-31 20:51:27 UTC (rev 3497)
@@ -95,6 +95,7 @@
var $_prefix = null;
var $_cache;
var $_dbInitialized = false;
+ var $_lastError = "";
/**
* Basic constructor, setting up a cache for all classes extending Model
@@ -137,6 +138,7 @@
// if the query generated an error, write a message to the sql
// error log file
if( !$result ) {
+ $this->_lastError = $this->_db->ErrorMsg();
include_once( PLOG_CLASS_PATH . "class/logger/loggermanager.class.php" );
$log =& LoggerManager::getLogger( "sqlerr" );
@@ -153,11 +155,19 @@
/**
* Returns the last error message from the database.
*
+ * @param driverError Set this field to true if interested in getting the error message as reported by
+ * the driver. Keep in mind that the error message might be gone after we've closed the connection
+ * (by calling the Close() method at the driver level) The only way to get the error message in
+ * that case (if any at all) is by setting this parameter to 'false'. If done so, this class will save
+ * the last error message and make it available via this method. This parameter defaults to false.
* @return A string containing the error message
*/
- function DbError()
+ function DbError( $driverError = false )
{
- return $this->_db->ErrorMsg();
+ if( $driverError )
+ return( $this->_db->ErrorMsg());
+ else
+ return( $this->_lastError );
}
/**
More information about the pLog-svn
mailing list