There's a problem that happens for Symfony 1 + sfDoctrineGuardPlugin that doesn't have a lot of information online. Getting to the point, the error message says: "Unknown column username", even when the column and field "username" is well defined (or it seems).

In our scenario, we have:

And it seems weird at first sight, because the User class HAS the "username" field, and also the table. However, if have any doubts, you can simply re-build the model using the symfony+doctrine commands. But the error will prevail.

Cause & Solution

This problem happens when the model clases are not well generated. Particularly in the ../lib/model/doctrine/base directory. You could probably find classes there that are not being used and mess with the inheritance. Or you could even find classes with the wrong @package (comment section before declaration).

The solution is to delete all the clases inside the base directory. Don't worry about that, because since they are base classes, they could be easily regenerated with the build commands. That way you'll make sure you erase all bad-defined classes.

Then, re-build the classes with the symfony+doctrine commands like:

php symfony doctrine:build-model
php symfony doctrine:build-forms
php symfony doctrine:build-filters

And that's it. Once you have all those classes cleared up you should be fine.