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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:55:38+00:00 2026-06-14T21:55:38+00:00

I have a little problem with Doctrine model hydrate() method. I use this method

  • 0

I have a little problem with Doctrine model hydrate() method. I use this method to hydrate an object of conrete model from a given array like so:

$model = new Doctrine\Model\Model;
$model->hydrate($model_array);

Everything works perfect when hydrating simple objects withou nested sub-models. Now the problem is I need to hydrate (using this method) an object that has nested objects (and some of them have also a nested objects).

If I were using HYDRATE_RECORD that would be fine but all the records from query would be returned as objects which means more memory consumption. Therefore I am using HYDRATE_ARRAY and on demand hydrate that concrete array to an object.

Let’s suppose I have a model A that has nested models AB, AC (by one to many), AD and AC has another nested model ACE. After print_r of the A array we could see this structure:

A Array (
    ...
    ab Array ( ... )
    ac Array (
        AC Array (
            ...
            ace Array ( ... )
        )
        AC Array (
            ...
            ace Array ( ... )
        )
        ...
    )
    ad Array ( ... )
)

Normally after using hydrate I would assume that this would be my object:

A Object {
    ...
    ab Object { ... }
    ac Array (
        AC Object {
            ...
            ace Object { ... }
        }
        AC Object {
            ...
            ace Object { ... }
        }
        ...
    )
    ad Object { ... }
}

But instead of this I get this structure:

A Object {
    ...
    ab Array ( ... )
    ac Array (
        AC Array (
            ...
            ace Array ( ... )
        )
        AC Array (
            ...
            ace Array ( ... )
        )
        ...
    )
    ad Array ( ... )
}

So only the main model got converted to an object.
Do You know about a way how to get all the nested model arrays got converted to an objects like the supposed result?

And no, I cannot use HYDRATE_RECORD when querying the DB.

  • 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-14T21:55:39+00:00Added an answer on June 14, 2026 at 9:55 pm

    Looking through documentation if stumbled upon this.

    Have you given a try to fromArray instead of hydrate?

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

Sidebar

Related Questions

I have little problem with printing data like this, I have written script like
I have little problem on the here http//site.com/detial.php?verifyID=$parametre i want this like short url
I have a little Problem with Doctrine and Yaml: Here is my Model: Keyword:
I have a little problem with multiline UILabel, my UILabel text like starts from
I have a little problem: I have this in my model: validates :title, :presence
I have little problem with fancybox jquery library. when I use this simple line
I have a little problem. This is my code: stackPanelShapesContainer = new StackPanel(); InitializeStackPanle();
I have a little problem with converting a char string array to an unsigned
I have this little problem with json. //real json var json1 = {test1:TEST1,test2:TEST2,test3:TEST3,test4:TEST4}; alert(json.test1);
I have a little problem calling the button1_click event of form1 from my form2

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.