I am new to cakephp and
I can’t seem to get the relationship right in the following scenario:
I have a database with 2 tables, clients and events. Clients can have many events, events belongs to one client, but sometimes events don’t belong to a client, or the client detail is not known when the event needs to be entered.
Is there a way to have cakephp not enforce a relationship?
It won’t matter. If you do a Event->find( … ) and there is no linked Client the results will simply have an empty ‘Client’ => array( ) in the returned results.
As for not entering a client, make sure you can select an empty option in the drop-down where you would select a client for the event. Also, make sure the field allows validation to pass when you try and save a blank client_id.
Nothing tricky here – the basics will work just fine for you out of the box.