Sun 03 Apr 2005 03:05:42 PM UTC, original submission:
Hi,
I'm creating some custom modules for PHP-groupware and I like to use PEAR-DB in my modules.
But a nameclash between PEAR-DB and PHPgw's DB-class makes this very difficult. (PHPgw on my Debian terminates on loading PEAR-DB with: "Fatal error: Cannot redeclare class db in /usr/share/php/DB.php on line 271") I've seen many people complain about this problem in the newsgroups, but I've not seen any sollution for PHP-groupware so far.
After some research, I fixed this problem for myself by the following steps:
-rename [path_to_phpgw]/phpgwapi/inc/class.db.inc.php
to [path_to_phpgw]/phpgwapi/inc/class.db_phpgw.inc.php
-change the class name 'db' to 'db_phpgw' at least in the following files:
[path_to_phpgw]/phpgwapi/inc/class.db_mysql.inc.php
[path_to_phpgw]/phpgwapi/inc/class.db_pgsql.inc.php
[path_to_phpgw]/phpgwapi/inc/class.db_oracle.inc.php
[path_to_phpgw]/phpgwapi/inc/class.db_mysql.inc.php
[path_to_phpgw]/phpgwapi/inc/class.db_sapdb.inc.php
[path_to_phpgw]/phpgwapi/inc/class.db_[db_you_actually_use].inc.php
-Replace "CreateObject('phpgwapi.db')" with "CreateObject('phpgwapi.db_phpgw')"
in the following files:
phpgwapi/inc/class.setup.inc.php
phpgwapi/inc/functions.inc.php
This is a very fundamental change, but I think the impact in PHPgroupware should not be too big, since only the framework and the setup scripts are supposed to create instances of PHPgroupware's db class. And personally I believe supporting PEAR-DB in the modules is worth this change.
My sollution only lasts until I upgrade my phpgroupware installation (when files mentioned above are overwritten), so I hope my sollution can help in finding a more permanent sollution for all people who build custom phpgroupware modules.
I'm currently using 'phpGroupWare API version 0.9.16.005' on Debian Unstable.
Regards,
Peter van der Meer
|