Inheritance And Overloading In Yii

Hi All,

In my situation, I need to write a Transaction model into databases depends on its flag. If its flag is "external" then should be written in default db while it is flag as "internal" should be written in "test_db".

I am successfully implementing it with the help of [font="Courier New"]multiactiverecord [/font]extension. I used inheritance, the model is called [font="Courier New"]Transaction [/font]with the [font="Courier New"]connectionId [/font]is using default db connection. Then, I made another class called [font="Courier New"]TransactionTest [/font]which inherit from Transaction. I overloaded the connectionId method to return "test_db" instead of default db.

Everything seemed okay until I forgot to start the db server where the "test_db" resided. I am expecting an error will occur when the system tried to access [font="Courier New"]TransactionTest[/font]. Unfortunatelly, there is no error. When the test_db is down, it will use the default db connection. No error is occured.

My current work around is to copy the Transaction entirely to [font="Courier New"]TransactionTest [/font]and override the [font="Courier New"]connectionId [/font]in [font="Courier New"]TransactionTest[/font]. It gave me another trouble since I am in the development phase where the class keep changes. Now, I have to change bot files.

Any help on this?

Thank you very much in advance.