doctrine default values and relations
- by Skirmantas
Concept: Lets say we have table Properties with columns id and name (lets say with some predefined values: "Good" "Better" "Best"). Another table Users has column property_id with many to one relation on Properties (property_id = id). Users has default value on property_id, lets say 1 which means "Good". We might have another table analogue to Users however with default property, lets say "Better". What I need is ability to change default value for Users or other tables in administrator's panel.
In mysql I can set default value for column like this:
ALTER TABLE <Table> CHANGE <Column> DEFAULT <NEW_DEFAULT_VALUE>
I can retrieve default value:
SELECT DEFAULT(<Column>) FROM <Table> LIMIT 1
Is it possible to achieve this concept with Doctrine?
What I actually need is such method in my table class:
class UserTable extend Doctrine_Table {
/* ... */
getDefaultProperty() {
}
setDefaultProperty($value) {
/* $value can be either integer or Doctrine_Record */
}
}