Jump to content

Using Multiple lookup tables in cakephp


Recommended Posts

I have been learning php and have put together a simple site to track vehicle faults and repairs, but now i am trying to transfer it to cakephp framework to make it easier to work with. My problem is that i have 4 tables,

  1. the fault and repair
  2. a list of vehicles
  3. a list of symptoms
  4. a list of fault codes.

Each repair can have 3 vehicles, 3 symptoms and 3 codes relating to it so i have lookup table to link the fault/repair id to the symptoms, code and vehicles.

i have setup basic code for the vehicle , symptom and fault code models like this:

public $hasAndBelongsToMany = array(
'Fault' =>
'className' => 'Fault',
'joinTable' => 'Faults_vehicles',
'foreignKey' => 'vehicle_id',
'associationForeignKey' => 'fault_id'

and this lets me search for any faults in the faults table with a given vehicle ID, and this works fine. My problem is how can i set it up so i can do a search for faults in the Faults table with a given vehicle ID and a given symptom ID that have a matching Fault code ID.

I am very new to php and have only just started using cakephp so sorry in advance if this makes no sense at all.

thanks for your time




Link to post
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.