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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:02:18+00:00 2026-05-16T08:02:18+00:00

For a website i’m building I need to check wether a location has contracts,

  • 0

For a website i’m building I need to check wether a location has contracts, these locations can have contracts linked directly to them or when there part of a larger organisation also have contracts that are linked to the organisation.

I am trying to use a DQL query to first check if there are contracts linked directly and then if there are any linked via an organistion with this query:

    $q = self::createQuery("l")
        ->select('sl.sc_id, sl.type, so.sc_id, so.type, l.naam, l.loc_id, l.straat, l.telefoon, l.plaats, l.postcode, l.huisnummer, l.huisnummer_achtervoegsel, o.naam')
        ->from('Locatie l, l.Organisatie o, l.Sc sl, o.Sc so')
        ->orderBy('o.naam, l.naam')
        ->execute();

It does what I want in so much as that it returns an array with all the data I need:

array(13) { 
["loc_id"]=> string(2) "93" ["org_id"]=> string(1) "9" ["naam"]=> string(12) "test" 
["Organisatie"]=> array(4) { ["org_id"]=> string(1) "9" ["naam"]=> string(3) "test"
["Sc"]=> array(1) { [0]=> array(6) { ["sc_id"]=> string(1) "1" ["sc_nummer"]=> NULL ["type"]=> string(6) "All-in" } } } 
["Sc"]=> array(0) { } 

}

The problem is the duplicate [“Sc”] key, because in php when an array has duplicate keys, that last key overwrites the first (what i read anyway), this makes it impossible to make a check like:

if(!empty($SC) or !empty($SC2) {}

I can’t seem to figure out how to make doctrine name one of the keys differently or maybe even merge the two.

I tried using INDEXBY but that changed the key inside the [‘SC’] array and not [‘SC’] itself.

Any ideas?

  • 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-16T08:02:19+00:00Added an answer on May 16, 2026 at 8:02 am

    You can rename it within the query. So in your example, that would only change on of the sc_id to something like

    [...] sl.sc_id AS your_new_key [...]
    

    See http://www.doctrine-project.org/projects/orm/1.2/docs/manual/dql-doctrine-query-language/en#select-queries:aggregate-values

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

Sidebar

Related Questions

My website makes a lot of requests. I often need to cancel all current
My website has been giving me intermittent errors when trying to perform any Ajax
My website has an Atom feed and I want to make it easier to
website needs to go live which i have placed on client server.i have gven
Website is running on a web host where we don't have access to a
Website in reference: http://www.imvu-e.com/products/ht/clients/test/ Notice on the tables how I have a newline separating
My website structure has a root /index.php, some files as /directory/index.php and some as
My website has a large number of readers every day. I wanted to track
My website is set to UTF-8, do i have to set my forms also
Website using .NET Framework v3.5, SQL Server 2008, written in C# I have a

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.