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 7673437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:30:40+00:00 2026-05-31T16:30:40+00:00

Elloo, I have two doctrine entities and am trying to do left join however

  • 0

Elloo, I have two doctrine entities and am trying to do left join however i’m getting a message “Error: Class GR\Entity\AccountEvents has no association named Accounts”. i have looked at other solutions on stackoverflow however none has helped.

here is my code

<?php
namespace GR\Entity;
/**
 * 
 * @Table(name="accounts")
 * @Entity
 */
class Accounts
{
    /**
     *
     * @var integer $id
     * @Column(name="id", type="integer",nullable=false)
     * @Id
     * @GeneratedValue(strategy="IDENTITY")
     */
    private $id;

    /**
     * @Column(type="string",length=255,nullable=false)
     * @var string
     */
    private $name;

    /**
     * @Column(type="string",length=255,nullable=false)
     * @var string
     */
    private $email;

    /**
     * @Column(type="string",length=255,nullable=false)
     * @var string
     */
    private $password;

    /**
     * @Column(type="datetime",nullable=false)
     * @var datetime
     */
    private $created_at;

    /**
     * @OneToMany(targetEntity="AccountEvents", mappedBy="Accounts") 
     */ 
    private $accountevents;  

    public function __get($property)
    {
        return $this->$property;
    }

    public function __set($property,$value)
    {
        $this->$property = $value;
    }
}

..and

<?php
namespace GR\Entity;
/**
 * 
 * @Table(name="account_events")
 * @Entity
 */
class AccountEvents
{
    /**
     *
     * @var integer $id
     * @Column(name="id", type="integer",nullable=false)
     * @Id
     * @GeneratedValue(strategy="IDENTITY")
     */
    private $id;


    /**
      * @var Accounts $accounts
      *
      * @Column(name="account_id", type="integer", nullable=false)
      * @ManyToOne(targetEntity="Accounts", inversedBy="accountevents")
      * @JoinColumn(name="accounts_id", referencedColumnName="id")
      */
    private $accounts;

    /**
     * @Column(type="string",length=255,nullable=true)
     * @var string
     */
    private $event;

    /**
     * @Column(type="datetime",nullable=false)
     * @var datetime
     */
    private $created_at;


    public function __get($property)
    {
        return $this->$property;
    }

    public function __set($property,$value)
    {
        $this->$property = $value;
    }
}

..and my query

$query = $this->em->createQueryBuilder()
                       ->select('a, e')
                       ->from('GR\Entity\AccountEvents', 'e')
                       ->leftJoin('e.Accounts', 'a')
                       ->query();


$results = $query->getResult();

Thanks in advance

  • 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-05-31T16:30:42+00:00Added an answer on May 31, 2026 at 4:30 pm

    I have solved it and here is the solution below (i’m using ZF 1.11, doctrine 2 and nolasnowball library)

    In Accounts entity change

    /**
     * @OneToMany(targetEntity="AccountEvents", mappedBy="accounts")
     * @var \Doctrine\Common\Collections\Collection
     */
    private $accountevents;
    

    In AccountEvents entity change

    /**
     * @ManyToOne(targetEntity="Accounts")
     * @JoinColumn(name="accounts_id", referencedColumnName="id")
     * @var GR\Entity\Accounts
     **/
    private $accounts;
    

    To fetch resultset

    $query = $this->em->createQueryBuilder()
                       ->select('a, e')
                       ->from('GR\Entity\Accounts', 'a')
                       ->leftJoin('a.accountevents', 'e');
    
    $results = $query->getQuery()->getResult();
    

    here is the full code http://pastie.org/3626654

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

Sidebar

Related Questions

I am trying to change the class of all div element with the id
I am trying to match words with up to two missing letters with regex.
I'm experimenting with jQuery Mobile and have run into a problem on my Windows
I'm A bit stuck with a regular expression. I have a string in the
I use QPainter to drawText on QPrinter; however, there is a problem. I hope
Lets say that I have 10,000 regexes and one string and I want to
Need a clarification while looking at calculating a running checksum. Assume I have data
I get a linker error with the following code: #include <regex> int main() {
I've been trying to get a c3p0 db connection pool configured for Jetty (7.4.1.v20110513),
I have overloaded << operator such that it write to file and also on

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.