Skip to content

Get data from 2 tables joint in abother table #219

@absmugz

Description

@absmugz

Hi,
I have a simple database which uses joins as follows :

Table 1 contains portfolio items:
Portfolio_items
portfolio_id
name
description

Table 2 contains portfolio categories:
Categories
categories_id
name

Table 3 contains the portfolio categories join ids:
Portfolio_categories
portfolio_id
categories_id

So what I would like to do is get all 1 record from Portfolio_items and all the categories that 1 portfolio item is in.
Basically please point me in the right direction of how to get data from Portfolio_items with multiple and Categories where the joines are in id's in Portfolio_categories using MY_Model.

Do I have to write custom functions like :

class A_model extends MY_Model
{
public function Example()
{
Custom ActiveRecord query goes here
}
}

Can you please give me a rough example using the table structure above ? Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions