0

On a Symfony exploration project, I have a model using doctrine NestedSet behaviour. Since the data is prepared in a flat file, I wrote a conversion utility to generate corresponding YAML. It turns out that processing NestedSet YML of around 100 records (max_depth=4) consumes over 40MB of PHP memory, which is not available to me.

Is there a work-around to this problem?

I'm thinking of 2 possible solutions.

  1. Write an equivalent PHP script to populate objects & save them
  2. Insert data via SQL statements, the challenge being to compute the left & right nodes

What do Symfonians suggest?

3
  • Pre-order travel algo explained: sitepoint.com/hierarchical-data-database-2 Commented Nov 30, 2011 at 7:36
  • How is hierarchy represented in your flat file? Commented Nov 30, 2011 at 9:24
  • It has the foll fields: level, id, name, parent_id. So if fruit is a child of food, then the CSV data has 2 lines: 1=>[0, f1, Food, ] 2=>[1, f2, Fruit, f1] Commented Dec 2, 2011 at 10:54

2 Answers 2

1

I suggest you insert the data in several times, one time per level starting at level 0, for instance.

Sign up to request clarification or add additional context in comments.

Comments

0

Option 2 was better.

I wrote a simple macro in Excel to compute the lgt and rgt values required for the pre-order tree. Logic as mentioned here: http://www.sitepoint.com/hierarchical-data-database-2/ The same Excel utility would convert values to a SQL query that could be dumped via file.

Going through the fixtures/object route exceeded the allowed memory limit.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.