Jump to content

Using Multiple lookup tables in cakephp


jay543_uk

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' =>
array(
'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

j

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.