Ok, I understand your point, but that would lend you to the
possibility of have a single address, being of a seller or a client,
to be owned by a client AND by a seller any number of times, and I
dont think you want to share an address that way.

I can think in a possible solution, by having a parent table for both
client and seller tables, for grouping purposes. For example:

People
---------------------------
id
personType_id

Client
---------------------------
id
people_id

Seller
---------------------------
id
people_id

PersonTypes
---------------------------
id
name

Addresses
---------------------------
id
person_id

and your associations should be:

Person hasMany address
Person hasOne client
Person hasOne seller
Person belongsTo PersonType
Client belongsTo People
Seller belongsTo People
PersonType hasMany Person
Address belongsTo People

In that way, you're handling both clients and sellers in just one
table, the same way you are handling the address table. Hope this
helps.

On Aug 21, 5:24 pm, Marcello <[EMAIL PROTECTED]> wrote:
> that's possible, although its a little troublesome
>
> i mean, i only gave an example of why im usingHABTM
>
> the whole system is using only a address table, for the purpose of
> maintenance
>
> if im intending to change something about my address, that would be
> much more clear to have only one table/controller/model to handle that
>
> that's my focus right now, make a system that will give less problems
> on maintence, specially because i got more than one client for this
> system, so it may have some minor changes that would be awfully sad to
> make in many tables
>
> english isnt my native language to, so no worries ;)
>
> thanks for all the replys
>
> On 20 ago, 20:24, nachopitt <[EMAIL PROTECTED]> wrote:
>
> > Right, i forgot to tell you that. I prefer to let the RDBMS handle
> > this, instead of having to write more code in the app. But changing
> > from MyISAM to InnoDB can have its drawbacks.
>
> > Anyway, Marcello I can see by looking at your model that you pretend
> > to have both client and seller addresses in one table named Addresses,
> > and thats why I suppose you are looking after aHABTMassociation.
> > However, you can eliminate this association and have a pair of two
> > hasMany and their respective belongsTo associations if you split the
> > actual address table in two more being client_addresses and
> > seller_addresses.
>
> > I hope I was clear enough, if not please correct me.
>
> > Sorry about my english, it's not my native language.
>
> > On Aug 20, 4:24 pm, Joel Perras <[EMAIL PROTECTED]> wrote:
>
> > > That will only work if your database engine supports foreign key
> > > constraints, such as MySQL InnoDB.  The default MySQL MyISAM engine
> > > does not support any type of referential integrity; you can set the
> > > FOREIGN KEY/REFERENCES attributes, but they will be ignored.
>
> > > Other database implementations may also be lacking foreign key
> > > constraints, but my experience is localized to PostgreSQL and MySQL.
>
> > > It's probably worth opening up a ticket concerning your issue, since
> > > one would expect that the default behaviour for 'dependent' would
> > > allow the deletion of the associated entry in the join table,
> > > effectively unlinking the two model records in question.  I agree with
> > > Dave, however, in that in most cases you would not want to delete the
> > > associated records in aHABTMrelationship (as opposed to the entry in
> > > the join table) for obvious reasons.
>
> > > -Joel.
>
> > > On Aug 20, 5:12 pm, Marcello <[EMAIL PROTECTED]> wrote:
>
> > > > im a little new to referential integrity in the database directly,
> > > > could you enligthen me?
>
> > > > i got 5 tables
>
> > > > Clients AddressClient Addresses
> > > > Sellers AddressSeller
>
> > > > what i need is, when i delete a client or a seller, it should also
> > > > delete his addresses, BUT when i delete a address the client or seller
> > > > must remain untouched
>
> > > > On 20 ago, 12:45, nachopitt <[EMAIL PROTECTED]> wrote:
>
> > > > > Why don't you just do it the way its suppossed to be? By adding
> > > > > referential integrity to the database. For example:
>
> > > > > CREATE TABLE / ALTER TABLE ...
> > > > > ...
> > > > > FOREIGN KEY (foreignTableName_id) REFERENCES foreignTableName ON
> > > > > DELETE CASCADE;
>
> > > > > On Aug 20, 9:21 am, Marcello <[EMAIL PROTECTED]> wrote:
>
> > > > > > the main reason for usinghabtmis because address table is shared
> > > > > > among the whole system
>
> > > > > > clients use them, sellers, and so on
> > > > > > and a client can have ANY NUMBER of addresses
> > > > > > the same for seller
> > > > > > so i cant put a foreign key in any of the two tables
>
> > > > > > thats why i must useHABTM
>
> > > > > > On 20 ago, 10:50, Dave J <[EMAIL PROTECTED]> wrote:
>
> > > > > > > Not sure if I made sense in my previous post, but basically this 
> > > > > > > is a
> > > > > > > case in which, if you're in a situation where you need todelete
> > > > > > > dependent records in anHABTMrelationship..... you might need to
> > > > > > > think if the relationship should be anHABTMone at all... or if a
> > > > > > > simpler hasMany would do the job just as well.
>
> > > > > > > On Aug 20, 2:44 pm, Dave J <[EMAIL PROTECTED]> wrote:
>
> > > > > > > > I dont think it works forHABTMrelations....  also for the reason
> > > > > > > > that it might be unsafe to do so. By deleting all related 
> > > > > > > > records, you
> > > > > > > > might also be deleting records which are referenced to by other
> > > > > > > > entries in the join table.
>
> > > > > > > > On Aug 20, 4:03 am, Marcello <[EMAIL PROTECTED]> wrote:
>
> > > > > > > > > it does not work (gives no error, but does not remove the 
> > > > > > > > > dependent
> > > > > > > > > side)
>
> > > > > > > > > On 19 ago, 22:26, Marcello <[EMAIL PROTECTED]> wrote:
>
> > > > > > > > > > dependent is exactly what i was looking for
>
> > > > > > > > > > thanks!
>
> > > > > > > > > > On 19 ago, 22:11, Joel Perras <[EMAIL PROTECTED]> wrote:
>
> > > > > > > > > > > Take a look 
> > > > > > > > > > > athttp://book.cakephp.org/view/66/models#deleting-data-516
> > > > > > > > > > > .  The 'dependent' parameter can also be set in the model 
> > > > > > > > > > > association
> > > > > > > > > > > definition.
>
> > > > > > > > > > > Hope that's what you were looking for.
> > > > > > > > > > > -J.
>
> > > > > > > > > > > On Aug 19, 8:52 pm, Marcello <[EMAIL PROTECTED]> wrote:
>
> > > > > > > > > > > > i got 2 tables linked by aHABTMrelationship
>
> > > > > > > > > > > > when ideletetable record 1 i want todeletethe 
> > > > > > > > > > > > relationship with
> > > > > > > > > > > > table and the table 2 record as well
> > > > > > > > > > > > but when ideletefrom table 2 i want to keep table 1 
> > > > > > > > > > > > record
>
> > > > > > > > > > > > is there any feature in cakephp forcascadinginhabtm?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to