Welcome Guest, Not a member yet? Register   Sign In
Datamapper with multiple tables
#1

[eluser]timobg[/eluser]
Hi,

I am developing an application for handling logging data and I want to achieve logging in multiple database tables for more faster and better presentation later.

I want to make a DMZ datamapper 1.8.2 model to use multiple tables which are being created dynamically with the time when stored data grows.

So my question is, how could I handle multiple tables with one model. I tried to call the method reinitialize_model(), but without success ???

If anybody has done, please, share ...
Any thoughts are appreciated ...

Code:
$log_obj = new Log_m("new_table_name");

$log_obj->reinitialize_model();



Code:
$log_obj = new Log_m();

$log_obj->table = "new_table_name";

$log_obj->reinitialize_model();

I am not using datamapper cache.

Regards
#2

[eluser]WanWizard[/eluser]
Datamapper uses $this->table internally, so resetting this property should be sufficient to swap tables.

This will work if all tables are defined EXACTLY the same, all part of the same database, and if the model doesn't have any relations (as the table names are part of internal relationship definitions).

There is no need to use reinitialize_model(), that will only re-apply the config.
#3

[eluser]timobg[/eluser]
Thank you for the reply. It works.




Theme © iAndrew 2016 - Forum software by © MyBB