Ask your Symfony questions! Pay money and get answers fast! (more info)

Doctrine: Call to a member function getFieldName() on a nonobject Symfony

  • SOLVED

I wrote some code to take an XML schema and auto-generate a yaml schema. The XML is an export from a FileMaker Pro database. This is the schema that I was auto-generated by my code:

OldAppellations:
connection: doctrine
tableName: old_appellations
columns:
appellations___sql: { type: text }
appellationsapcode_sql: { type: text }
appellationsappellation_sql: { type: text }
appellationscolor_sql: { type: text }
appellationscountry_sql: { type: text }
appellationsregion_sql: { type: text }
appellationsregion_for_link_sql: { type: text }
appellationssubt_sql: { type: text }
appellationstaster_appel_sql: { type: text }
appellationstotal_r_sql: { type: text }
appellationstype_sql: { type: text }
export_record_id_sql: { type: text }


This is the only yaml in a file called config/doctrine/old_appellations-schema.yml

Then I:

./symfony doctrine:build --model --forms --filters

Then:

./symfony doctrine:generate-module tastingnotes old_appellations OldAppellations

Then:

./symfony cc

I point my browser at old_appellations/index.

I get this error:

Notice: Undefined index: o__appellations in /home/lkrubner/dev/tastingnotes/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Hydrator/Graph.php on line 302

Notice: Undefined index: in /home/lkrubner/dev/tastingnotes/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Hydrator/Graph.php on line 303

Fatal error: Call to a member function getFieldName() on a non-object in /home/lkrubner/dev/tastingnotes/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Hydrator/Graph.php on line 304


See screenshot.

Any thoughts?

[UPDATE]

I'm adding a different screenshot, which shows the database table. See the first version of this question if you want to see a screenshot of the error that I got.

Answers (2)

2010-12-08

Loban Rahman answers:

Of the top of my head the first thing I'd do is replace that triple underscore column with one. Just in case doctrine got confused. If it then works then you've found a doctrine bug.


Loban Rahman comments:

Jose has a point about stale model files. Use doctrine:clean-model-files. Schema spacing problems would surface while building, not when viewing.


Lawrence Krubner comments:

Hmm, no dice. Following the advice of Jose and you, I tried:

./symfony doctrine:clean-model-files

./symfony doctrine:build --model --forms --filters

./symfony cc


I deleted everything and started over -- but still the same bug.


Lawrence Krubner comments:

You were right! It was the 3 underscores! I changed the 3 underscores to just 1 underscore so my schema now looks like this:


OldAppellations:
connection: doctrine
tableName: old_appellations
columns:
appellations_sql: { type: text }
appellationsapcode_sql: { type: text }
appellationsappellation_sql: { type: text }
appellationscolor_sql: { type: text }
appellationscountry_sql: { type: text }
appellationsregion_sql: { type: text }
appellationsregion_for_link_sql: { type: text }
appellationssubt_sql: { type: text }
appellationstaster_appel_sql: { type: text }
appellationstotal_r_sql: { type: text }
appellationstype_sql: { type: text }
export_record_id_sql: { type: text }


Rebuilt the model and now the error is gone!

2010-12-09

José Nahuel Cuesta Luengo answers:

Is this the first build of your model? If not, try removing all the php files in your base doctrine folders (lib/model/doctrine/base at least), and <em>then</em> do your doctrine:build --model --forms --filters.

Otherwise, it may be some missing space or some indentation problem in your schema file.


Lawrence Krubner comments:

Good thought. This never seemed to be a problem with Propel, but it definitely came up before with Doctrine. This is my first project working with Doctrine.


José Nahuel Cuesta Luengo comments:

Lawrence, I cannot get your error in a clean project. I copied your schema.yml file and went through your steps but I didn't get any error message. Is there any other "odd" fact about your project?

I tried it with the latest symfony 1.4. Which version are you using?