Question

I know naming conventions for tables used by plugins generally start with the name of the plugin and then the model pluralized. For example lets say I had a plugin called Poll, with a model also called PollPoll and another model called PollTag then the resulting table names would be poll_polls and poll_tags. They would also have a habtm relationship so what is the convention for that table name? I believe it would poll_poll_polls_poll_tags, although it is a little redundant it makes sense since the first poll_ represents the name of the plugin, while poll_polls and poll_tags relates to the models.

Also have any naming conventions changed for plugins in 1.3? Is the above stated correct?

Was it helpful?

Solution

Not sure about cake 1.3 (I'm not using it yet), but this if you're right this sounds like a perfectly acceptable case of breaking convention and defining the jointable, and foreign keys in the model relationships and possibly in the plugin.

Why does your plugin require a join table? Seems like a design issue. Perhaps there is a case where this is needed, but if I had a HABTM relation with a plugin, I would add a modelname column to the plugin's table, rather than have to create a new table for each model I wanted to use the plugin.

OTHER TIPS

It's actually not yet a convention that "tables used by plugins generally start with the name of the plugin and then the model pluralized."

The only place that idea is introduced is in an example in the book, which actually says, "it is recommended that you name your plugin controllers something relatively unique in order to avoid namespace conflicts with parent applications ... you might want to be creative with controller names, or prepend the name of the plugin to the classname."

Your Table/Model/Controller/View names must follow normal CakePHP naming conventions, and take reasonable precautions to avoid namespace clash. So it would be perfectly fine to have a "foo_orders" table for a "foo_order" model in plugin Bar.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top