Don’t use IsValid in your Doctrine Models – a warning

September 9, 2010 in Doctrine, PHP, Web Development

Recently for a project i’ve been making heavy use of Doctrine. In one of the models I had a method to check to see if the object was valid under a certain set of conditions. I named this function isValid .. and it had 2 params. Little did I know that this was actually overriding an existing deep rooted isValid which gets fired on saving the object to the DB. Bummer.

So this is a quick warning to all you Doctrine users. Unless you want to actually override the isValid method for saving, call your check method function something else!