Re: Automating an MDB2 Change Log

From: Date: Fri, 07 Nov 2008 14:15:16 +0000
Subject: Re: Automating an MDB2 Change Log
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-29405@lists.php.net to get a copy of this message
If I understand correctly, then you have a code file in which you do something like this: *** test php *** <?php require_once 'db_connection.php'; $mdb2->query('SELECT DATABASE()'); *** end of test *** and you expect 'SELECT DATABASE()' to wind up in the 'audits' table. Unfortunately, $mdb2 is not an object of type AuditMDB2 but rather of type MDB2_mysql or some such. So your custom methods never get called. My favorite way to confirm this in the absence of a debugger is simply to place a print statement inside the method I think I'm running (remember to remove the print statement after and don't use profanity jik). A (nother) side note. Your conceptual understanding of object overloading is lacking. When you create a class, or in this case when one is created for you, it has all of the methods and properties defined in itself and its ancestors. If you derive a class from the starting point and overload some methods on it, the original class remains unaffected. Creating an object of original class type has no connection whatsoever to the new drived class type. Creating an object of the derived type enjoys all the troubles and benefits that you've added to the new class. Here's an even more confusing article on it: http://en.wikipedia.org/wiki/Type_polymorphism Ok, so how are you going to solve this? You may be able to overload the way that you have, but you would need to do so by setting $mdb2 to a new object of type AuditMDB2. Oh, you've an infinite loop in your code by the way, but I'm sure that will become apparent when you get the methods to run. One thing you might try is customizing the debug handler: http://www.installationwiki.org/MDB2#Extending_MDB2 I kind of like this idea, but it's not clear from the article how you're going to obtain the actual SQL for your audit. The good thing about this method is that you almost certainly will not want to constantly be auditing sql statements. It's an extra load on the system that will eventually add up to the largest database table the universe has ever seen. Another thing you might try if you're intent on continuing down the road you've started is to create a custom module (see further down the same article). Not sure where that leads or ends up. Um, good luck. -- View this message in context: http://www.nabble.com/Automating-an-MDB2-Change-Log-tp19554927p20381302.html Sent from the Pear - General mailing list archive at Nabble.com.

« previous php.pear.general (#29405) next »