Prevent Propel from inserting empty strings
问题 How can I prevent Propel ORM from inserting empty strings when a column is not set? CREATE TABLE user ( uid INTEGER PRIMARY KEY AUTO_INCREMENT, email VARCHAR(255) NOT NULL UNIQUE, -- No default value ... ) Engine InnoDB ... ; Propel allows $user = new User(); $user->save(); . I have tried setting SQL_MODE but it doesn't help. 回答1: The correct way to do this is with a validator in the schema and then a check using the validate() method in your code. Here's an example: <database ...> <table ...