<?php

// =================
// helpers
// =================
function getChild($parent_id)
{
    $sql = "
        select 
            t.*, d.*
        from exp_relationships as r
        inner join exp_channel_titles as t on t.entry_id=r.rel_parent_id
        inner join exp_channel_data as d on d.entry_id=t.entry_id
        where r.rel_child_id = '$parent_id'
        and t.status = 'open'
        and d.field_id_74 = 'Yes'
        order by d.field_id_15
        ";
    $re = $this->EE->db->query($sql);
    $re = $re->result_array();
    if (!empty($re))
    {
        return $re;
    }
    return false;
}
// ================
// 
// ================
function getParent($child_id, $channel_id)
{
    $sql = "
        select 
            t.*
        from exp_relationships as r
        inner join exp_channel_titles as t on t.entry_id=r.rel_child_id
        where r.rel_parent_id = '$child_id'
        and t.channel_id = '$channel_id'
        ";
    $re = $this->EE->db->query($sql);
    $re = $re->result_array();
    if (!empty($re))
    {
        return $re;
    }
    return false;
}