Database Comments with Symfony and Propel

I’ve always used propel with Symfony, but occasionally I’ve looked over the fence to have a look at doctrine. One of the things I knew doctrine could do was allow documenting of MySql with comments.

I googled for England for a propel equivalent, no joy.

I’ve been working on a brand new project at work and I’m using the new(ish) sfPropelORMPlugin. Yesterday a colleague told me that you just had to add the following code to the Table and Column declarations in the yaml schema file:


_attributes: { description: ‘My Description’ }

For a table this is easy:

propel:
  my_table:
    _attributes: { description: 'My Description' }

I tried this for the “name” column :

propel:
  my_table:
    _attributes: { description: 'My Description' }
    id: ~
    userid: { type: varchar(255) } #Uncommented
    name:
      _attributes { description: "The Name of the User" }
      type: varchar(255)

This failed when I built the model giving:

PHP Warning: htmlspecialchars() expects parameter 1 to be string, array given in /home/adavies/projects/misc/cmd/trunk/plugins/sfPropelORMPlugin/lib/addon/sfPropelDatabaseSchema.class.php on line 809

I passed an array instead of a string for _attributes. In fact the new plugin is just clever enough to accept the following in the column declaration:


name: { description: 'My Column Description', type: varchar(255) }

So now you can document your dB. What are you waiting for?

Note to self I really must re-investigate some of the code plugins in WordPress for pasting raw code and prettifying it.