CakePHP - Tables with compound name in relationship HABTM
So... I have 2 tables:
banner_channel
banners
I need to create a table to relate the banners (ta开发者_JAVA技巧ble banners) with the channels of the banners (table banner_channel).
Obs.: I cant rename table banner_channel to channel only because I already have this table in database.
Maybe, the new table is:
banners_banner_channel
or
banners_channel
? I dont know.
Anyway, thanks.
Sorry for my english... I'm brazilian 8DFirst of all according to the cakePHP naming conventions the table you named banner_channel should be in plurals: banner_channels
As for the naming, it should be: banners_banner_channels
CakePHP cheat sheat
banners_banner_channel
is the correct table name according to what you have already.
just have a look at all the options in the habtm relations as you will have to set them all manually. instead of just doing 'hasAndBelongsToMany' => array('BannerChannels')
you will need to set everything according to this
first example: you will need atleast the following, className
, joinTable
, foreignKey
, associationForeignKey
and with
the rest you can tweak to your needs
精彩评论