cvs: pear /MDB2 MDB2.php
| From: | Lukas Smith | Date: | Thu, 06 May 2004 15:50:18 +0000 |
| Subject: | cvs: pear /MDB2 MDB2.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-19258@lists.php.net to get a copy of this message | ||
lsmith Thu May 6 11:50:18 2004 EDT
Modified files:
/pear/MDB2 MDB2.php
Log:
- use __construct() and __destruct() (PHP4 BC hacks are provided)
- fixed getAfterID() to better integrate with getBeforeID()
http://cvs.php.net/diff.php/pear/MDB2/MDB2.php?r1=1.29&r2=1.30&ty=u
Index: pear/MDB2/MDB2.php
diff -u pear/MDB2/MDB2.php:1.29 pear/MDB2/MDB2.php:1.30
--- pear/MDB2/MDB2.php:1.29 Sun May 2 08:05:44 2004
+++ pear/MDB2/MDB2.php Thu May 6 11:50:18 2004
@@ -43,7 +43,7 @@
// | Author: Lukas Smith <smith@backendmedia.com> |
// +----------------------------------------------------------------------+
//
-// $Id: MDB2.php,v 1.29 2004/05/02 12:05:44 lsmith Exp $
+// $Id: MDB2.php,v 1.30 2004/05/06 15:50:18 lsmith Exp $
//
/**
@@ -776,6 +776,13 @@
{
// {{{ properties
/**
+ * php version used
+ * @var integer
+ * @access public
+ */
+ var $phpversion = 5;
+
+ /**
* index of the MDB2 object within the $GLOBALS['_MDB2_databases'] array
* @var integer
* @access public
@@ -986,7 +993,7 @@
/**
* Constructor
*/
- function MDB2_Driver_Common()
+ function __construct()
{
$db_index = count($GLOBALS['_MDB2_databases']) + 1;
$GLOBALS['_MDB2_databases'][$db_index] = &$this;
@@ -994,6 +1001,17 @@
$this->PEAR();
}
+
+ function MDB2_Driver_Common()
+ {
+ static $register_shutdown;
+ if (isset($register_shutdown)) {
+ $register_shutdown = true;
+ register_shutdown_function('_MDB2_shutdownTransactions');
+ }
+ $this->phpversion = 4;
+ $this->__construct();
+ }
// }}}
// {{{ __toString()
@@ -2280,7 +2298,7 @@
if (!$this->supported['auto_increment']) {
return $thid->nextID($seq_name, $ondemand);
}
- return;
+ return 'NULL';
}
// }}}
@@ -2308,13 +2326,14 @@
/**
* returns the autoincrement ID if supported
*
+ * @param miced id value as returned by getBeforeId()
* @param string $table name of the table
* @return mixed MDB2 Error Object or id
* @access public
*/
- function getAfterID($table)
+ function getAfterID($id, $table)
{
- return;
+ return $id;
}
// }}}
@@ -2535,7 +2554,7 @@
*
* @access private
*/
- function _MDB2_Driver_Common()
+ function __destruct()
{
if ($this->in_transaction && !MDB2::isError($this->rollback())) {
$this->autoCommit(true);
@@ -2820,7 +2839,7 @@
*/
function getRowCounter()
{
- return $this->rownum + $this->offset;
+ return $this->rownum + 1 + $this->offset;
}
// }}}
@@ -2970,4 +2989,18 @@
$db->debug_output .= $message.$db->getOption('log_line_break');
}
+function _MDB2_shutdownTransactions()
+{
+ reset($GLOBALS['_MDB2_databases']);
+ $j=count($GLOBALS['_MDB2_databases']);
+ for($i=0; $i<$j; next($GLOBALS['_MDB2_databases']),$i++) {
+ $db_index= key($GLOBALS['_MDB2_databases']);
+ if ($GLOBALS['_MDB2_databases'][$db_index]->in_transaction
+ &&
!MDB2::isError($GLOBALS['_MDB2_databases'][$db_index]->rollback())
+ ) {
+ $GLOBALS['_MDB2_databases'][$db_index]->autoCommit(true);
+ }
+ }
+}
+
?>
\ No newline at end of file