one-to-many with many only having the foreign key

one-to-many with many only having the foreign key

raffy4284raffy4284 Posts: 7Questions: 2Answers: 1

so, based on this: https://editor.datatables.net/manual/php/array-joins
I can't find a way say to have a one-to-many (without a link table) where the "one" part doesn't have the foreign key, whereas the "many" part has the foreign key. It seems that both need to have a foreign key.
Is there a way for me to query this with the "one" part not having the foreign key?
table:
One Job, many Evidence:

---------------------
JobID,     JobName
--------------------

---------------------
EvidenceID,      EvidenceName,     JobID (foreign key)
-------------------

or would I need to use where for this?

Answers

  • raffy4284raffy4284 Posts: 7Questions: 2Answers: 1
    edited August 2015

    note:
    I tried doing this via join:

    ....
    ->join(
            Join::inst( 'Evidence', 'array' )
                ->join(
                          'EvidenceID', 'JobID'
                )
    ....
    

    at first, i did ->join(....->join('JobID','EvidenceID'))....then I realized that JobID was being treated as the foreign key in Jobs, and EvidenceID as the foreign key for Evidence table (or so from what I'm understanding)

    EDIT: I might have figured out what's wrong with my code LOL

This discussion has been closed.