cvs: pear /DB_NestedSet NestedSet.php
| From: | Daniel Khan | Date: | Thu, 25 Sep 2003 11:19:53 +0000 |
| Subject: | cvs: pear /DB_NestedSet NestedSet.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-13076@lists.php.net to get a copy of this message | ||
datenpunk Thu Sep 25 07:19:53 2003 EDT
Modified files:
/pear/DB_NestedSet NestedSet.php
Log:
- CVS Comments were missing.
- Major API improvements have been done
- Got rid of some methods
- Amde the order field consistent with lft/rgt values
- Now it will be able to get a preorderwalk-sorted output without recursions
- Fixed possible bug in moves were the moving tree gets changed by the move operation itself
- Added getParent(), getSiblings(), createRightNode()
- Added API Version output with api()
- Started to get rid of PEAR inheritance
- Started to get consistent error reporting
Index: pear/DB_NestedSet/NestedSet.php
diff -u pear/DB_NestedSet/NestedSet.php:1.43 pear/DB_NestedSet/NestedSet.php:1.44
--- pear/DB_NestedSet/NestedSet.php:1.43 Thu Sep 25 06:26:37 2003
+++ pear/DB_NestedSet/NestedSet.php Thu Sep 25 07:19:53 2003
@@ -16,7 +16,7 @@
// | Authors: Daniel Khan <dk@webcluster.at> |
// | Jason Rust <jason@rustyparts.com> |
// +----------------------------------------------------------------------+
-// $Id: NestedSet.php,v 1.43 2003/09/25 10:26:37 datenpunk Exp $
+// $Id: NestedSet.php,v 1.44 2003/09/25 11:19:53 datenpunk Exp $
//
// CREDITS:
@@ -36,7 +36,7 @@
// Error and message codes
define('NESE_ERROR_RECURSION', 'E100');
-define('NESE_DRIVER_NOT_FOUND', 'E200');
+define('NESE_ERROR_NODRIVER', 'E200');
define('NESE_ERROR_NOHANDLER', 'E300');
define('NESE_ERROR_TBLOCKED', 'E010');
define('NESE_MESSAGE_UNKNOWN', 'E0');
@@ -61,7 +61,7 @@
*
* @author Daniel Khan <dk@webcluster.at>
* @package DB_NestedSet
-* @version $Revision: 1.43 $
+* @version $Revision: 1.44 $
* @access public
*/
@@ -175,13 +175,20 @@
*/
var $_restcache = false;
+ var $_packagename = 'DB_NestedSet';
+
+ var $_majorversion = 1;
+
+ var $_minorversion = 3;
+
+
/**
* @var array Map of error messages to their descriptions
*/
var $messages = array(
NESE_ERROR_RECURSION => 'This operation would lead to a recursion',
NESE_ERROR_TBLOCKED => 'The structure Table is locked for another database
operation, please retry.',
- NESE_DRIVER_NOT_FOUND => 'The selected database driver wasn\'t found',
+ NESE_ERROR_NODRIVER => 'The selected database driver %s wasn\'t found',
NESE_ERROR_NOTSUPPORTED => 'Method not supported yet',
NESE_ERROR_NOHANDLER => 'Event handler not found',
NESE_ERROR_PARAM_MISSING=> 'Parameter missing',
@@ -226,6 +233,7 @@
$this->flparams = array_flip($this->params);
$this->sequence_table = $this->node_table . '_' .
$this->flparams['id'];
$this->secondarySort = $this->flparams['norder'];
+ register_shutdown_function('_DB_NesetSet');
}
// }}}
@@ -247,9 +255,8 @@
if (!class_exists($classname)) {
$driverpath = dirname(__FILE__).'/NestedSet/'.$driver.'.php';
if(!file_exists($driverpath) || !$driver) {
- return new PEAR_Error('E200',"The database driver
'$driver' wasn't found");
+ return PEAR::raiseError("factory(): The database driver '$driver'
wasn't found", NESE_ERROR_NODRIVER, PEAR_ERROR_TRIGGER, E_USER_ERROR);
}
-
include_once($driverpath);
}
return new $classname($dsn, $params);
@@ -992,8 +999,7 @@
}
// Insert the new node
- $sql[] = sprintf('INSERT INTO %s SET %s',
-
+ $sql[] = sprintf('INSERT INTO %s SET %s',
$this->node_table,
$qr);
@@ -1993,6 +1999,19 @@
}
// }}}
+
+
+ function api() {
+ return array(
+ 'package:'=>$this->_packagename,
+ 'majorversion'=>$this->_majorversion,
+ 'minorversion'=>$this->_minorversion,
+ 'version'=>sprintf('%s.%s',$this->_majorversion,
$this->_minorversion),
+ 'revision'=>"$Revision: 1.44 $"
+ );
+ }
+
+
// {{{ setAttr()
/**
@@ -2252,7 +2271,7 @@
* Generic class for node objects
*
* @autor Daniel Khan <dk@webcluster.at>;
-* @version $Revision: 1.43 $
+* @version $Revision: 1.44 $
* @package DB_NestedSet
*
* @access private