Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9096923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T23:58:44+00:00 2026-06-16T23:58:44+00:00

I am looking at how to create self-relationship (upsteam) join in ORM Datamaper. my

  • 0

I am looking at how to create self-relationship (upsteam) join in ORM Datamaper.
my self – relation class looks:

<?php
class Prospect extends DataMapper{

    var $has_one =array(
        'parent' => array(
            'class' => 'prospect',
            'other_field'=>'prospect'
        ),
        'prospect' => array(
        'other_field' => 'parent'
        )
    );




}

and I try to list

include_related (parent)
$p->include_related('parent')->get();

I have had error
Fatal error: Cannot use object of type Prospect as array in [..]application/libraries/Datamapper.php on line 2739

I can do

$p->include_related('prospect')->get();

but in this case I have had a wrong join.

SELECT `prospects`.*, `prospect_prospects`.`id` AS prospect_id, `prospect_prospects`.`name` LEFT OUTER JOIN `prospects` prospect_prospects ON `prospects`.`id` = `prospect_prospects`.`parent_id`

Results shows relation parent -> child (downstream relation) not child-> parent (upstream relation)
I am lookig for:

SELECT `prospects`.*, `prospect_prospects`.`id` AS prospect_id, `prospect_prospects`.`name` LEFT OUTER JOIN `prospects` prospect_prospects ON `prospects`.`parent_id` = `prospect_prospects`.`id`

Any tips how to do it, and what I have to change it ? and how should look a good upstream relationship class / php code ?

ps: direct SQL query works brilliant.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T23:58:45+00:00Added an answer on June 16, 2026 at 11:58 pm

    OK, Problem solved
    variable parent is used in Datamapper library class to keep an array with relations, so ‘parent’ is restricted and it couldn’t be used at all. i.e. in my case. I have changed from parent to parent_company and all is working brilliant. (this is solved my left join problem as well).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am looking to setup a relationship where a user can create a post
I am looking for a tool that will allow me to create a self
I looking to create a custom calender with Zend Framework, I am hoping that
Im looking to create a control that would look like comic baloon. In WPF
I'm looking to create a portfolio using a Wordpress blog. On the summary page
I'm looking to create something like in this image. Each block would have an
I am looking to create a reg ex in JS that obtains 2 values
I'm looking to create a command line menu in powershell, with the options coming
I'm looking to create a table in html to be used to insert the
I'm looking to create a read-only table, and MYSQL permissions, I think, are the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.