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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:09:31+00:00 2026-05-23T22:09:31+00:00

I am designing a room booking system which has nine entities, which all relate

  • 0

I am designing a room booking system which has nine entities, which all relate to each other. In this specific instance I am retrieving 10-30 rows from the entity entry which has 25 properties. Each entry has one room which has 10 properties. I need all of the entry information as well as entry->room->id and entry->room->name. But it seems like doctrine is loading the entire room when I use Query::HYDRATE_ARRAY. It seems to be lazy-loading in Query::HYDRATE_OBJECT more easily.

So, I am wondering if using the Query::HYDRATE_OBJECT mode is faster or “better” than Query::HYDRATE_ARRAY / Query::HYDRATE_SCALAR/ Query::HYDRATE_SINGLE_SCALAR. Since I am reusing some older code I’d like to use HYDRATE_ARRAY but only if it won’t slow the application down.

  • 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-23T22:09:32+00:00Added an answer on May 23, 2026 at 10:09 pm

    My 2 cents:

    HYDRATE_OBJECT is best for when you plan on using a lot of business logic with your objects. Especially if you’re doing a lot of data manipulation. It’s also probably the slowest (depending on the situation).

    HYDRATE_ARRAY is usually reserved for when you only need a result and 1 degrees of relational data and it’s going to be used for printing/viewing purposes only.

    HYDRATE_NONE is another one I use when I’m only selecting a very small subset of data (like one or two fields instead of the entire row). This behaves much like a raw query result would.

    This might also be of interest http://www.doctrine-project.org/2010/03/17/doctrine-performance-revisited.html

    This is from the 1.2 docs but I think the Hydration tips apply in 2.0 http://doctrine.readthedocs.org/en/latest/en/manual/improving-performance.html

    Another important rule that belongs in this category is: Only fetch objects when you really need them. Doctrine has the ability to fetch “array graphs” instead of object graphs. At first glance this may sound strange because why use an object-relational mapper in the first place then? Take a second to think about it. PHP is by nature a precedural language that has been enhanced with a lot of features for decent OOP. Arrays are still the most efficient data structures you can use in PHP. Objects have the most value when they’re used to accomplish complex business logic. It’s a waste of resources when data gets wrapped in costly object structures when you have no benefit of that

    On using HYDRATE_ARRAY:

    Can you think of any benefit of having objects in the view instead of arrays? You’re not going to execute business logic in the view, are you? One parameter can save you a lot of unnecessary processing:

    $blogPosts = $q->execute(array(1), Doctrine_Core::HYDRATE_ARRAY);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

for designing purposes i need to truncate all DB which has lots of FK's.
In designing class with multiple/nested has-a relationships, who should catch exceptions? I guess this
Designing AIR application which has to have server side push or notification, don't know
Designing forms has always been fun, but getting them to send email on the
When designing a stock management database system for sales and purchases what would be
I need to develop an interior designing software :) Much like a virtual room
While designing applications it is a very good practice to have all the business
im designing a system where i will have multiple users uploading large amount of
When designing a new system or getting your head around someone else's code, what
i am working on asp.net i want to make a chat room which should

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.