I have few problems with setting PropelORM to work with multiple databases. I couldn't find anything useful in the documentation.
Generating schemas from multiple databases
I prefer to make a change to database schema first and then run
$ propel-gen . reverse
to get schema.xml. What if my system consists of more then one database? Can it generate multiple schemas? I know from the documentation buildtime-conf.xml has to be created but it doesn't do anything for me.
Generating classes
Let's say I created to different schemas blog.schema.xml and platform.schema.xml. Is it possible to:
have a different class prefix for each schema? In build.properties I can set propel.classPrefix
but that will work globally for each schema.
have a different project name for each schema? Again in the build.properties I can set propel.project
and that will create a certain directory in classes directory. Right now all classes will go to the same place. If I will use the same table name in both schemas one class will overwrite the other.
The solution I can come on my own is to have a 2 different directories setup for a certain database however I would prefer more elegant solution.
Can you post the <database>
line from your Schema?
As long as you have the following:
<database package="blog" name="blog" defaultIdMethod="native">
Inside of your blog.schema.xml it should generate a new directory for you. If you let propel lazyload those for you though, you are right you'll get collisions, so I just manually pre-pended something to my tables in the schema.xml
(which might not be the most efficient thing to handle things).
But you can do something like:
in blog.schema.xml:
<table name="users" phpName="blogUsers" idMethod="native">
in platform.schema.xml:
<table name="users" phpName="platformUsers" idMethod="native">
That worked fine for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With