Change Log

13 views
Skip to first unread message

Marcello Fontolan

unread,
Aug 28, 2014, 10:44:29 AM8/28/14
to redbe...@googlegroups.com
  Hi,

  We are developing a new version of a software and we decided to use RB.
  At this moment we are facing the need of log in a table each change made by the user.
  For example, if a customer name is change, we should log the old name, the new name, who and when this change happen in a log table.
  In our current software this is made in a object method called by every DAO.
  Where is the best way to do it in RB?
  
  regards,

  Marcello
  

gabor

unread,
Aug 28, 2014, 11:03:38 AM8/28/14
to redbe...@googlegroups.com
Not sure if this one still works, but here you go:

https://github.com/gabordemooij/redbean/blob/RedBeanPHP3_5_X/RedBean/Plugin/TimeLine.php

cheers
Gabor

Marcello Fontolan

unread,
Aug 28, 2014, 6:23:27 PM8/28/14
to redbe...@googlegroups.com
You think this works for 4.0 version?


--
You received this message because you are subscribed to a topic in the Google Groups "redbeanphp" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/redbeanorm/qnW7BceD9QM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to redbeanorm+...@googlegroups.com.
To post to this group, send email to redbe...@googlegroups.com.
Visit this group at http://groups.google.com/group/redbeanorm.
For more options, visit https://groups.google.com/d/optout.

gabor

unread,
Sep 2, 2014, 2:25:52 PM9/2/14
to redbe...@googlegroups.com


Probably not, but look it's just 20 lines or so.
Simply create a logger and listen for schema altering queries: 'ALTER', 'CREATE TABLE' and 'DROP TABLE'.


Marcello Fontolan

unread,
Sep 3, 2014, 9:51:52 AM9/3/14
to redbe...@googlegroups.com
Gabor,

I get my log plugin working, but this is not what I need.
Using RB 4.1 beta, the new "Debug" class is where I need put my code on!
Can I write my own "Debug" without edit the RB bean code?
If I extend the Debug class, how can I make RedBean use it?

My log will be saved into a database and I have to keep track of all changes, field by field.
I must have answer, for example, who and when change the name of a customer.
A plus is keep record of what was the OLD value and the NEW value.
Only keep the NEW value is good enought.

Thanks!!!

Regards

Marcello


2014-09-02 15:25 GMT-03:00 gabor <gabord...@gmail.com>:


Probably not, but look it's just 20 lines or so.
Simply create a logger and listen for schema altering queries: 'ALTER', 'CREATE TABLE' and 'DROP TABLE'.


gabor

unread,
Sep 3, 2014, 3:09:43 PM9/3/14
to redbe...@googlegroups.com

Something like this?

class MyLogger extends \RedBeanPHP\Logger\RDefault\Debug {
        public function output($out) {
                echo "save to database here... $out ";
                parent::output($out);
        }
}

$myLogger = new MyLogger;
R::getDatabaseAdapter()->getDatabase()->setDebugMode(true, $myLogger);

$person = R::dispense('person');
$person->name = 'John';
R::store($person);


Marcello Fontolan

unread,
Sep 3, 2014, 3:41:26 PM9/3/14
to redbe...@googlegroups.com
Perfect!!!

I will send you my "TimeMachine" logger when it is ready!!!

regards

Marcello


Reply all
Reply to author
Forward
0 new messages